Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to prepare trainingClasses for Neutral Network?

How to input labels for classes in NN. Are they like SVM give different labels to each class. I have not really understood how to create the training class for neural network?

How to prepare trainingClasses for Neutral Neural Network?

How to input labels for classes in NN. Are they like SVM give different labels to each class. I have not really understood how to create the training class for neural network?network? I do not know how to use it for training I have tried the following way: void mlp(cv::Mat& trainingData, vector<int>& index) { int input_neurons = 8; int hidden_neurons = 100; int output_neurons = 12; Mat layerSizes = Mat(3, 1, CV_32SC1); layerSizes.row(0) = Scalar(input_neurons); layerSizes.row(1) = Scalar(hidden_neurons); layerSizes.row(2) = Scalar(output_neurons);

Ptr<ml::ANN_MLP> mlp = ml::ANN_MLP::create();
mlp->setLayerSizes(layerSizes);
mlp->setTrainMethod(ml::ANN_MLP::SIGMOID_SYM);
mlp->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 1000, 0.00001f));
mlp->setTrainMethod(ml::ANN_MLP::BACKPROP,0.1f,0.1f);
mlp->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM, 1, 1);

Mat trainClasses;

cout << "Poker" << endl;
trainClasses.create(trainingData.rows, 12, CV_32FC1);
for (int i = 0; i < trainClasses.rows; i++)
{
    trainClasses.at<float>(i, index[i]) = 1.f;
}

cout << "Row of trainClass: " << trainClasses.cols << endl;
cout << "Row of trainData: " << trainingData.cols << endl;
cout << "Koker" << endl;
Ptr<ml::TrainData> td = ml::TrainData::create(trainingData, ml::ROW_SAMPLE, trainClasses);
mlp->train(td);
cout << "Training Done" << endl;

mlp->save("neural_network.xml");

}

When I am predicting, I am getting the following response: [-4.4227011e+0008,-404295997e+008,-4.4214237e+008,-4.3398125e+008,.......]

What is wrong and how to interpret the response from an ANN?

How to prepare trainingClasses train data for Neural Network?

How to input labels for classes in NN. Are they like SVM give different labels to each class. I have not really understood how to create the training class for neural network? I do not know how to use it for training I have tried the following way: void mlp(cv::Mat& trainingData, vector<int>& index) { int input_neurons = 8; int hidden_neurons = 100; int output_neurons = 12; Mat layerSizes = Mat(3, 1, CV_32SC1); layerSizes.row(0) = Scalar(input_neurons); layerSizes.row(1) = Scalar(hidden_neurons); layerSizes.row(2) = Scalar(output_neurons);

Ptr<ml::ANN_MLP> mlp = ml::ANN_MLP::create();
mlp->setLayerSizes(layerSizes);
mlp->setTrainMethod(ml::ANN_MLP::SIGMOID_SYM);
mlp->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 1000, 0.00001f));
mlp->setTrainMethod(ml::ANN_MLP::BACKPROP,0.1f,0.1f);
mlp->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM, 1, 1);

Mat trainClasses;

cout << "Poker" << endl;
trainClasses.create(trainingData.rows, 12, CV_32FC1);
for (int i = 0; i < trainClasses.rows; i++)
{
    trainClasses.at<float>(i, index[i]) = 1.f;
}

cout << "Row of trainClass: " << trainClasses.cols << endl;
cout << "Row of trainData: " << trainingData.cols << endl;
cout << "Koker" << endl;
Ptr<ml::TrainData> td = ml::TrainData::create(trainingData, ml::ROW_SAMPLE, trainClasses);
mlp->train(td);
cout << "Training Done" << endl;

mlp->save("neural_network.xml");

}

When I am predicting, I am getting the following response: [-4.4227011e+0008,-404295997e+008,-4.4214237e+008,-4.3398125e+008,.......]

What is wrong and how to interpret the response from an ANN?

click to hide/show revision 4
No.4 Revision

updated 2016-04-06 01:46:32 -0600

berak gravatar image

How to train data for Neural Network?

How to input labels for classes in NN. Are they like SVM give different labels to each class. I have not really understood how to create the training class for neural network? I do not know how to use it for training I have tried the following way: way:

void mlp(cv::Mat& trainingData, vector<int>& index)
{
    int input_neurons = 8;
    int hidden_neurons = 100;
    int output_neurons = 12;
    Mat layerSizes = Mat(3, 1, CV_32SC1);
    layerSizes.row(0) = Scalar(input_neurons);
    layerSizes.row(1) = Scalar(hidden_neurons);
    layerSizes.row(2) = Scalar(output_neurons);

Scalar(output_neurons);

    Ptr<ml::ANN_MLP> mlp = ml::ANN_MLP::create();
 mlp->setLayerSizes(layerSizes);
 mlp->setTrainMethod(ml::ANN_MLP::SIGMOID_SYM);
 mlp->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 1000, 0.00001f));
 mlp->setTrainMethod(ml::ANN_MLP::BACKPROP,0.1f,0.1f);
 mlp->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM, 1, 1);

 Mat trainClasses;

 cout << "Poker" << endl;
 trainClasses.create(trainingData.rows, 12, CV_32FC1);
 for (int i = 0; i < trainClasses.rows; i++)
 {
     trainClasses.at<float>(i, index[i]) = 1.f;
 }

 cout << "Row of trainClass: " << trainClasses.cols << endl;
 cout << "Row of trainData: " << trainingData.cols << endl;
 cout << "Koker" << endl;
 Ptr<ml::TrainData> td = ml::TrainData::create(trainingData, ml::ROW_SAMPLE, trainClasses);
 mlp->train(td);
 cout << "Training Done" << endl;

 mlp->save("neural_network.xml");

}

}

When I am predicting, I am getting the following response: [-4.4227011e+0008,-404295997e+008,-4.4214237e+008,-4.3398125e+008,.......]response:

[-4.4227011e+0008,-404295997e+008,-4.4214237e+008,-4.3398125e+008,.......]

What is wrong and how to interpret the response from an ANN?