Problem traning Auto-Associative Neural network

asked 2014-07-03 08:24:58 -0500

alirezad gravatar image

updated 2014-07-03 08:25:56 -0500

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 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;


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:


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


Where I did wrong?!

edit retag flag offensive close merge delete