I'm trying to create an FFN to predict a continuous value. The code compiles but I get the following error when calling model.Train():
error: Mat::operator(): index out of bounds
terminate called after throwing an instance of 'std::logic_error'
what(): Mat::operator(): index out of bounds
Aborted (core dumped)
Here's the network:
FFN<> model;
model.Add<Linear<> > (train_x.n_rows, 20);
model.Add<Linear<> > (20, 30);
model.Add<Linear<> > (30, train_y.n_rows);
model.train(train_x, train_y); //train_x and train_y are arma::mat-s of shapes (8, 2000) and (1, 2000)
I found some issues similar to this, like #1525 and #1415, but couldn't solve it.
Any help would be appreciated. Thank you.
Hi there,
By default the FFN<> class uses NegativeLogLikelihood<> as a loss function, which is for classification problems. Since you're trying to predict a continuous value, this is now regression, so I think you'll need to use a loss function like mean squared error:
FFN<MeanSquaredError<>> model;
Hope this helps. :)
That did it. Thanks again @rcurtin ! :D
Glad to help :)
Most helpful comment
Hi there,
By default the
FFN<>class usesNegativeLogLikelihood<>as a loss function, which is for classification problems. Since you're trying to predict a continuous value, this is now regression, so I think you'll need to use a loss function like mean squared error:Hope this helps. :)