MATLAB: Simple Feedforward NNet questions

binary outputDeep Learning Toolboxfeedforwardneural network

Good day! I am new to neural networks and in Matlab nnet toolbox.
Basically, I want to re-implement a backpropagation feedforward neural network described from a journal/research paper. The info/parameters that I currently have are the ff: 1) it consists of 2 layers: 1 hidden, 1 output 2) 6 input neurons, 6 output neurons, 5 neurons in the hidden layer 3) the values in the input are all floating point numbers, and just binary numbers in the output 4) the activation functions are tansigmoid for the first layer, then logsigmoid for the second 5) I need to get a least mean square (LMS) error that is below 0.05. 6) no info provided about the learning rate or the momentum 7) I can generate training samples as many as needed (5000 was used)
and these are my trial codes so far:
inputs = rand([6, 6000]); outputs = randi([0,1],6, 6000); net = feedforwardnet(5); net = configure(net,inputs, outputs); net.layers{2}.transferFcn = 'logsig'; net.trainParam.epochs = 6000; net.trainParam.goal = 0.01; net = train(net,inputs,outputs);
I'm not using yet my data since I'm still thinking how to normalize my inputs. My problem is that when I try to use the network, the output is not a binary array but some floating point values. What should I do about it?
And any further thoughts/advices? I would really appreciate them. Thank you in advance.

Best Answer

Binary numbers in the output generally indicate a classifier. In which case I advise using patternnet, unit vector column targets (help ind2vec), trainscg training function, tansig hidden and softmax output activation functions (posterior probability estimates sum to unity). When the trained net is used, the index of the assigned class is obtained from vec2ind.
If it is not a classifier, use logsig output functions. To get binary outputs you can replace logsig with hardlim AFTER training OR convert the output to unipolar {0,1} binary using round.
For a I-H-O = 6-5-6 node topology, the number of unknown weights to estimate are Nw = (I+1)*H+(H+1)*O = 35+36 = 71.
If the default data division is used, the number of training cases is Ntrn = 0.7*N and the number of training equations is Neq = Ntrn*O = 4.2*N. The rule of thumb Neq/Nw >> 1 yields N >> 71/4.2 = 17. The guideline N > 30*17 = 510 should be sufficient. N ~ 5000 may be over the top.
MSEgoal = 0.1*(Neq-Nw)*mean(var(t,0,2))/Neq
Should be sufficient as should defaults for the remaining parameters.
Hope this helps.
Thank you for formally accepting my answer.
Greg