Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem traning Auto-Associative Neural network

hi I want to use a feed-forward ANN to make an Auto-Associative neural network. for this purpose I used CvANN_MLP. but the output does'nt make sense?! As you may know, in AAANN the output should be like input (with an small error). but the output of my program is Something weird! my code is as below:

cv::Mat RecWOHeader::calcFeatureFromMLP(double *inFeature, const int inFeatureSize, const int numOfFeatureToRetain)

{ cv::Mat_<int> layerSize(1,5); layerSize(0) = inFeatureSize; layerSize(1) = inFeatureSize; layerSize(2) = numOfFeatureToRetain; layerSize(3) = inFeatureSize; layerSize(4) = inFeatureSize;

CvANN_MLP ANN(layerSize, CvANN_MLP::SIGMOID_SYM);


cv::Mat trainData(1, inFeatureSize, CV_32FC1, inFeature);
cv::Mat trainClass(1, inFeatureSize, CV_32FC1, inFeature);

CvANN_MLP_TrainParams trainParameter(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER ,100000, 0.00001), CvANN_MLP_TrainParams::BACKPROP,.9, .7);
ANN.train(trainData, trainClass, cv::Mat(),cv::Mat(),trainParameter);

cv::Mat output;
ANN.predict(trainData, output);

std::cout << output;
return output;

}

for example when I run the following code:

    double input[5] = {.31,.234,.4,.78,.001};
cv::Mat output = calcFeatureFromMLP(input, 5, 2);

the output is as follow:

0.303862;0.230611;3.66626e-314;6.54944e-307;1.13305e-317

but the output that I want is the same as input:

.31;.234;.4;.78;.001

Where I did wrong?!

Problem traning Auto-Associative Neural network

hi I want to use a feed-forward ANN to make an Auto-Associative neural network. for this purpose I used CvANN_MLP. but the output does'nt make sense?! As you may know, in AAANN the output should be like input (with an small error). but the output of my program is Something weird! my code is as below:

cv::Mat RecWOHeader::calcFeatureFromMLP(double calcFeatureFromMLP(double *inFeature, const int inFeatureSize, const int numOfFeatureToRetain)

{ cv::Mat_<int> layerSize(1,5); layerSize(0) = inFeatureSize; layerSize(1) = inFeatureSize; layerSize(2) = numOfFeatureToRetain; layerSize(3) = inFeatureSize; layerSize(4) = inFeatureSize;

CvANN_MLP ANN(layerSize, CvANN_MLP::SIGMOID_SYM);


cv::Mat trainData(1, inFeatureSize, CV_32FC1, inFeature);
cv::Mat trainClass(1, inFeatureSize, CV_32FC1, inFeature);

CvANN_MLP_TrainParams trainParameter(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER ,100000, 0.00001), CvANN_MLP_TrainParams::BACKPROP,.9, .7);
ANN.train(trainData, trainClass, cv::Mat(),cv::Mat(),trainParameter);

cv::Mat output;
ANN.predict(trainData, output);

std::cout << output;
return output;

}

for example when I run the following code:

    double input[5] = {.31,.234,.4,.78,.001};
cv::Mat output = calcFeatureFromMLP(input, 5, 2);

the output is as follow:

0.303862;0.230611;3.66626e-314;6.54944e-307;1.13305e-317

but the output that I want is the same as input:

.31;.234;.4;.78;.001

Where I did wrong?!