I have been working on this for quite some time now but I am not able to figure out the problem here.I am working on Ubuntu in Opencv using eclipse. I am trying to train the neural network with some values.A few sample values are 62 63 45 0.175925925925926 0.285714285714286 0.247058823529412 1 49 51 37 0.190476190476190 0.274509803921569 0.200000000000000 1
Here is the entire loop of the neural network training. FILE* fid= fopen("treewall","r");
while (fscanf(fid,"%f",&a)==1)
{
printf("%f
",a);
trainsamplecount=trainsamplecount+1;
}
cout<<trainsamplecount<<endl;
rewind(fid);
float td[2000][7];
int numoftestpoints;
CvMat* traindata=cvCreateMat(trainsamplecount,6,CV_32FC1);
CvMat* trainclasses=cvCreateMat(trainsamplecount,1,CV_32FC1);
CvMat* samplewts=cvCreateMat(trainsamplecount,1,CV_32FC1);
CvMat* neurallayers=cvCreateMat(4,1,CV_32SC1);
CvMat traindata1,trainclasses1,neurallayers1,samplewts1;
cvGetRows(neurallayers,&neurallayers1,0,4);
cvSet1D(&neurallayers1, 0, cvScalar(6));
cvSet1D(&neurallayers1,1,cvScalar(3));
cvSet1D(&neurallayers1,2,cvScalar(3));
cvSet1D(&neurallayers1, 3, cvScalar(1));
// CvMat* outdata=Mat::ones(trainsamplecount/7,1,CV_8U);
// CvMat* testdata(numoftestpoints,7,CV_32FC1);
cout<<traindata->rows<<endl;
cout<<traindata->cols<<endl;
int i=0,j=0;
if(fid)
{
for(int i=0;i<trainsamplecount;i++)
fscanf(fid,"%f %f %f %f %f %f %f ",&td[i][0],&td[i][1],&td[i][2],&td[i][3],&td[i][4],&td[i][5],&td[i][6]);
for (i=0;i<trainsamplecount;i++)
{
cout<<i<<endl;
cvGetRow(traindata,&traindata1,i);
cvSetReal2D(&traindata1,i,0,(float)td[i][0]);
cvSetReal2D(&traindata1,i,1,(float)td[i][1]);
cvSetReal2D(&traindata1,i,2,(float)td[i][2]);
cvSetReal2D(&traindata1,i,3,(float)td[i][3]);
cvSetReal2D(&traindata1,i,4,(float)td[i][4]);
cvSetReal2D(&traindata1,i,5,(float)td[i][5]);
cvGetRow(trainclasses,&trainclasses1,i);
cvSet1D(&trainclasses1,i,cvRealScalar(1));
cvGetRow(samplewts,&samplewts1,i);
cvSet1D(samplewts,i,cvRealScalar(1));
}
}
But this loop terminates at the statement cvGetRow(trainclasses,&trainclasses1,i); Before it used to dispaly a bad argument error at the line cvSet1D(samplewts,i,cvRealScalar(1));
由于我无法考虑解决办法,请帮助我解决这一问题。