Provides a method to create a simple neural network model which should be enough for tabular data classification tasks. The model consists of `nn_linear` layers, there are no dropouts and the activation function between the layers is `nnf_relu`, whereas the last one is `nnf_softmax`. The user can provide demanded architecture of the layers and select a softmaxes dimension.

create_model(
  train_x,
  train_y,
  neurons = c(32, 32, 32),
  dimensions = 2,
  seed = 7
)

Arguments

train_x

numeric, scaled matrix of predictors used for training. Here it is used for getting its size to build suitable neural network.

train_y

numeric, scaled vector of target used for training Here it is used for getting its size to build suitable neural network.

neurons

numeric, vector of integers describing the architecture. Notation c(8,16,8) means 3 layer neural network with 8,16 and 8 neurons in 1st, 2nd and 3rd layer. Default: c(32,32,32)

dimensions

integer 0,1 or 2 setting nnf_softmax dimension for classifier. Default: 2 (suggested to use 2 for classifier and 1 for adversarial)

seed

integer, seed for initial weights, set NULL for none. Default: 7.

Value

net,nn_module, neural network model

Examples

train_x <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3) train_y <- c(1, 2, 3) model <- create_model(train_x, train_y, neurons = c(16, 8, 16), dimensions = 1, seed=7)