Neural Network for 2 classes as input and 2 output

24 views (last 30 days)
Adnan Farooq Awan
Adnan Farooq Awan on 21 Sep 2017
Answered: Greg Heath on 21 Sep 2017
Hello
I have images of size 28x28x3 so the feature for each image will be 2352x1. I have two classes and each class have 700 images (for example) so the input variable x is 1400x2352 (format double) and labels are 1x1400 (700 0's ; 700 1's). Matlab code for the NN architecture is :
net = feedforwardnet([2 2 2]);
net.divideFcn = 'dividerand';
net.divideParam.trainRatio = 0.7;
net.divideParam.valRatio = 0.15;
net.divideParam.testRatio = 0.15;
[net,tr] = train(net,x,target_labels);
the net is shown like this:
isn't should be 2 input, 10 hidden layers and 2 outputs?

Answers (1)

Greg Heath
Greg Heath on 21 Sep 2017
1. You made a transcription error. Your code erroneously shows [ 2 2 2] whereas the figure is consistent with [ 2 10 2]
2. You made a conceptual error: The net creation statement does not include input and output dimensions. It only states number of nodes for each hidden layer. Therefore you have 5 layers, input, output and 3 hidden.
3. The number of nodes in the input and output layers are determined by the dimensions of the input and target vectors, respectively.
4. Remember the numbers in the creation statement are the number of nodes in each hidden layer, the number of numbers is the number of hidden layers.
Hope this helps.
Thank you for formally accepting my answer
Greg

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!