问题
I'm trying to create a simple Neural Network in R using the nerualnet package. Instead of typing out all 784 input variables I am just using a . like is 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 no 'data' argument
回答1:
I don't know why that 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.
来源:https://stackoverflow.com/questions/31729775/using-all-input-variables-in-neuralnet-in-r