Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is neural network not predicting?
    primarykey
    data
    text
    <p>I am trying to train a neural network using backpropagation algo. in OpenCV 2.3. However it is not predicting correctly....not even on training dataset. Could anybody please help me find whats wrong here?</p> <p>training_feature_matrix - Nx69 matrix of float values</p> <p>training_age_matrix - Nx4 matrix of float values</p> <p>test_feature_matrix - Mx69 matrix of float values</p> <p>test_age_matrix - Mx4 matrix of float values</p> <p>the feature matrices (mentioned above) are like: [0.123435, 0.4542665, 0.587545, ...68-such values + last value '1.0 or 2.0' depending upon its male/female)</p> <p>the age-matrices (mentioned above) are like: [1, 0, 0 ,0; 1, 0, 0, 0; 0, 1, 0, 0; ...] here 1s show the class of age (baby, child, adult, old) the corresponding row of feature matrix belongs to.</p> <p>here is the code: I call 'mlp' function using above matrices as parameters)</p> <pre><code>cv::Mat mlp(cv::Mat&amp; training_feature_matrix, cv::Mat&amp; training_age_matrix, cv::Mat&amp; test_feature_matrix, cv::Mat&amp; test_age_matrix) { cv::Mat layers = cv::Mat(3, 1, CV_32SC1); layers.row(0) = cv::Scalar(69); layers.row(1) = cv::Scalar(36); layers.row(2) = cv::Scalar(4); // cout&lt;&lt;layers&lt;&lt;"\n"; CvANN_MLP ann; CvANN_MLP_TrainParams params; CvTermCriteria criteria; criteria.max_iter = 10000; criteria.epsilon = 0.001; criteria.type = CV_TERMCRIT_ITER + CV_TERMCRIT_EPS; params.train_method = CvANN_MLP_TrainParams::BACKPROP; params.bp_dw_scale = 0.1; params.bp_moment_scale = 0.1; params.term_crit = criteria; ann.create(layers, CvANN_MLP::SIGMOID_SYM); ann.train(training_feature_matrix, training_age_matrix, cv::Mat(), cv::Mat(), params); cv::Mat predicted(test_age_matrix.rows, 4, CV_32SC1); for(int i = 0; i &lt; test_feature_matrix.rows; i++) { cv::Mat response(1, 4, CV_32F); cv::Mat sample = test_feature_matrix.row(i); ann.predict(sample, response); for (int g = 0; g &lt; 4; g++) { predicted.at&lt;int&gt;(i,g) = response.at&lt;float&gt;(0,g); } } cout &lt;&lt; "\n"; cout &lt;&lt; ann.get_weights(0) &lt;&lt; "\n"; cout &lt;&lt; ann.get_layer_sizes() &lt;&lt; "\n"; cout &lt;&lt; ann.get_layer_count() &lt;&lt; "\n\n"; return predicted; } </code></pre> <p><strong>EDIT</strong> Also, the ann.get_weights(0) &amp; ann.get_layer_sizes() are returning garbage values but ann.get_layer_count() is returning correct value 3.</p> <p>Thanks :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload