Quantcast
Viewing all articles
Browse latest Browse all 19555

Errors when predicting from a Neutral Network

Hello everyone, I am trying to train a neutral network in opencv using one hidden layer network. Everything seems fine but the program crashes when the predict function for the model is called. Below is my code: float sc[6] = { 0.3, 0.5, 1, 1, 0.2, 0.4 }; float sc1[3] = { 0.75, 0.81, 0.93 }; float sc2[2] = { 0.2, 1}; Mat traindata = Mat(3,2,CV_32FC1,&sc); Mat trainlabel = Mat(3, 1,CV_32FC1,&sc1); Mat testdata = Mat(1, 2,CV_32FC1,&sc2); Ptr mlp = ml::ANN_MLP::create(); mlp->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM); mlp->setTrainMethod(ml::ANN_MLP::BACKPROP); mlp->setBackpropMomentumScale(0.1); mlp->setBackpropWeightScale(0.1); mlp->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 1000, 1e-6)); Mat layers = Mat(3, 1, CV_32SC1); layers.row(0) = Scalar(2); layers.row(1) = Scalar(3); layers.row(2) = Scalar(1); //layers.row(3) = Scalar(5); mlp->setLayerSizes(layers); mlp->train(traindata,ml::ROW_SAMPLE,trainlabel); Mat responses = Mat(3,1,CV_32FC1); mlp->predict(testdata,responses); float result = responses.at(0, 0); The error message is given below: Unhandled exception at 0x00007FFE0076855C (opencv_world310d.dll) in fetchvideoapp.exe: 0xC0000005: Access violation reading location 0x000001D3A69DF000. [errormessage.png](/upfiles/14613656623495311.png) Your assistance will be duly appreciated. Regards.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>