Ask Your Question
0

Create a layer for artificial neural network of openCV2

asked 2013-10-28 03:27:14 -0600

stereomatching gravatar image

updated 2013-10-28 03:52:42 -0600

berak gravatar image

According to this blog, it create the labels as this way

    cv::Mat layers = cv::Mat(4, 1, CV_32SC1); //create 4 layers

    layers.row(0) = cv::Scalar(2); //input layer accepts x and y
    layers.row(1) = cv::Scalar(10);//hidden layer
    layers.row(2) = cv::Scalar(15);//hidden layer
    layers.row(3) = cv::Scalar(1); //output layer returns 1 or -1

But in the book, it create the layers as following

Mat layers(1,3,CV_32SC1);
layers.at<int>(0)= TrainData.cols;
layers.at<int>(1)= nlayers;
layers.at<int>(2)= numCharacters;

1 : The blog use rows to save the parameters but the book use cols to save the parameters.Are they the same thing?Do I have to change the way of writing, reading the xml according to the way of saving the parameters(any issues I do not mention have to take care)?

2 : What is the order of the layers?As I guess(uncertain)

  1. The feature numbers of each sample
  2. number of layers
  3. ~ Last(assume 4 == last in this case) - 1
  4. Classes(The kinds of data want to classify. ex : '0', '1', ..., '9')
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-10-28 09:35:54 -0600

berak gravatar image

it won't matter, if you use Mat layers(1,3,CV_32SC1); or Mat layers(3,1,CV_32SC1);

just decide for one and stick with it.

layers is just a one dimensional vector, each element contains the node-count for this layer, the 1st element is the input layer, the last one is the outpt layer, all inbetween are for the hidden ones.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-28 03:27:14 -0600

Seen: 624 times

Last updated: Oct 28 '13