Using all input variables in a neural network in R
I am trying to create a simple neural network in R using the nerualnet package. Instead of entering all 784 input variables, I just use a. as suggested in this thread: neural network using all input variables?
But I am getting this error
> digitnet <- neuralnet(label ~ ., trainingset, hidden = 4)
Error in terms.formula (formula): '.' in formula and without 'data' Argument
+3
source to share
1 answer
I don't know why this doesn't work, but you can always use the following:
myform <- as.formula(paste0('label ~ ',
paste(names(trainingset[!names(trainingset) %in% 'label']),
collapse = ' + ')))
and then:
digitnet <- neuralnet(myform, trainingset, hidden = 4)
And it will use all 784 input variables in the neural network model.
+2
source to share