Commit 223cdcd0 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed compilation of some samples; fixed ANN_MLP::predict

parent e368f17c
......@@ -262,9 +262,9 @@ public:
int cols = layer_sizes[j];
layer_out = Mat(dn, cols, CV_64F, data);
Mat w = weights[i].rowRange(0, layer_in.cols);
Mat w = weights[j].rowRange(0, layer_in.cols);
gemm(layer_in, w, 1, noArray(), 0, layer_out);
calc_activ_func( layer_out, weights[i] );
calc_activ_func( layer_out, weights[j] );
layer_in = layer_out;
}
......@@ -682,6 +682,8 @@ public:
train_backprop( inputs, outputs, sw, termcrit ) :
train_rprop( inputs, outputs, sw, termcrit );
trained = true;
return iter;
}
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
#include "opencv2/ml.hpp"
using namespace cv;
using namespace cv::ml;
int main( int /*argc*/, char** /*argv*/ )
{
......@@ -34,8 +35,9 @@ int main( int /*argc*/, char** /*argv*/ )
samples = samples.reshape(1, 0);
// cluster the data
EM em_model(N, EM::COV_MAT_SPHERICAL, TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 300, 0.1));
em_model.train( samples, noArray(), labels, noArray() );
Ptr<EM> em_model = EM::train( samples, noArray(), labels, noArray(),
EM::Params(N, EM::COV_MAT_SPHERICAL,
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 300, 0.1)));
// classify every image pixel
for( i = 0; i < img.rows; i++ )
......@@ -44,7 +46,7 @@ int main( int /*argc*/, char** /*argv*/ )
{
sample.at<float>(0) = (float)j;
sample.at<float>(1) = (float)i;
int response = cvRound(em_model.predict( sample )[1]);
int response = cvRound(em_model->predict2( sample, noArray() )[1]);
Scalar c = colors[response];
circle( img, Point(j, i), 1, c*0.75, FILLED );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment