Search code examples
rr-caretnnet

Hyperparameter tuning for neural net (nnet) in caret in R


I am constructing a neural net model in R using caret package and my code is as follows:

model <- train(RS_LAI~S2REP_LF+PSRI_ES+IRECI+NDVIRE+B11_ES+B7+TCARI_LF+MCARI+WDRVI
               , data = Data, 
               method = "nnet", trControl = controlparameters,
               linout = TRUE)

At the end when the model runs the result I get is the final value of size and decay. Here I suppose, size is the number of hidden layers, but I am confused what is the number of nodes its using in each layer? How can I get that? I think the number of nodes is also an important parameter to tune, but caret doesn't give that option.


Solution

  • You are using nnet , if you read the help page:

    Fit single-hidden-layer neural network, possibly with skip-layer connections.

    So it is 1 layer and the size parameter is the number of nodes or units, as you can see from the same help page:

    size: number of units in the hidden layer. Can be zero if there are skip-layer units.

    You can try to use neuralnet, it specifies up to 3 layers and your hyperparameters would be the number of nodes in each layer.