Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to initialize neural network?

Hello everyone. I have question; how to initalize Neural Network? I implemented Neural Network in MATLAB, and now I want to do same in OpenCV. Basically, I have training data as Mat (size 110 x 2), and my train classes have size (110 x 1). Here is code I am trying to compile, but it throws exception ( something about number of rows and columns).

Mat_<int> layers(4,1,CV_16U); layers(0) = 2; // input layers(1) = 100; // hidden layers(2) = 100; // hidden layers(3) = 1; // output, 1 pin per class. ann->setLayerSizes(layers); ann->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM,0,0); ann->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 300, 0.0001)); ann->setTrainMethod(ml::ANN_MLP::BACKPROP, 0.0001); ann>train(trainData, ml::ROW_SAMPLE, trainClass);

I also tried other options for number of layers (I use 110 for layers(0), etc.) but it failed.

How to initialize neural network?

Hello everyone. I have question; how to initalize Neural Network? I implemented Neural Network in MATLAB, and now I want to do same in OpenCV. Basically, I have training data as Mat (size 110 x 2), and my train classes have size (110 x 1). Here is code I am trying to compile, but it throws exception ( something about number of rows and columns).

Mat_<int> layers(4,1,CV_16U);
 layers(0) = 2; // input
 layers(1) = 100; // hidden
 layers(2) = 100; // hidden
 layers(3) = 1; // output, 1 pin per class.
 ann->setLayerSizes(layers);
 ann->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM,0,0);
 ann->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 300, 0.0001));
 ann->setTrainMethod(ml::ANN_MLP::BACKPROP, 0.0001);
 ann>train(trainData, ml::ROW_SAMPLE, trainClass);

trainClass);

I also tried other options for number of layers (I use 110 for layers(0), etc.) but it failed.