generate_stan_code_cat {bnns}R Documentation

Internal function to generate Stan Code for Neural Networks with Categorical Response

Description

This function generates Stan code for modeling a categorical response using neural networks with multiple layers. The generated code supports customizable activation functions for each layer and softmax-based prediction for the categorical output.

Usage

generate_stan_code_cat(num_layers, nodes)

Arguments

num_layers

Integer. Number of layers in the neural network.

nodes

Integer vector. Number of nodes in each layer. The length of this vector must match num_layers, and all values must be positive.

Details

The Stan code includes the following components:

Supported activation functions for the hidden layers:

The categorical response (y) is assumed to take integer values from 1 to K, where K is the total number of categories.

Value

A string containing the Stan code for the specified neural network architecture and categorical response model.

See Also

generate_stan_code_bin(), generate_stan_code_cont()

Examples

# Generate Stan code for a neural network with 3 layers
num_layers <- 3
nodes <- c(10, 8, 6) # 10 nodes in the first layer, 8 in the second, 6 in the third
stan_code <- generate_stan_code_cat(num_layers, nodes)
cat(stan_code)


[Package bnns version 0.1.2 Index]