Reputation: 3834
I am trying to use nnet in R, and encounter a problem for using softmax.
I am trying to builda three layer network, with input layer have 25 neurons, hidden layer have 25 neurons, output layer only have one neuron. Here is how to reproduce the problem.
library('nnet')
X <- replicate(25, rnorm(40))
y <- sample(0:1,40,replace=T)
mynnet <- nnet(X, y, size = 25,
softmax = T,
rang = 0.8,
maxit = 2000,
model=TRUE)
When I run this piece of code, I got a error:
Error in nnet.default(X, y, size = 25,
softmax = T, rang = 0.8, maxit = 2000, :
'softmax = TRUE' requires at least two response categories
What 'requires at least two response categories' means? And how to fix it? Thanks.
Upvotes: 3
Views: 3718
Reputation: 57686
softmax
is meant for fitting classification networks with a factor response variable. If you have a real-valued response, you probably want to fit a regression neural network, which can be obtained with linout=TRUE
.
Upvotes: 2