MATLAB: Define Multilayer perceptron with 28 neuron in hidden layer

mlpneural classification

hi
I have problem with define Multilayer perceptron neural network.first I create a mlp with newp() function and try to 28 neuron for network but trainc can not perform then create a feedforward network with hardlim and 28 neuron in hidden layer and perform trainc and try to make this network like a mlp but did not work again if i change network training minimum gradiant reached very soon. however how can I make a mlp network for calassification with n neuron in hidden layer?

Best Answer

Try to run the classification examples and demos in the documentation. Use the commands help and doc to better understand all of the functions you will use. For example:
help newpr
doc newpr
or the newer
help/doc patternnet
For c classes use target matrices with columns from the unit matrix eye(c). Use ind2vec for converting class indices (1:c) to unit matrix columns.
Use tansig hidden node activation functions, a softmax output activation function and the trainscg training function.
The number of hidden nodes is obtained by trial and error. I try to use the smallest acceptable value.
Each input column vector is assigned to the class corresponding to the maximum component of the corresponding unit output column vector. The index of the assigned class can be obtained using vec2ind.
The number of classification errors is obtained from
sum(assignedclassindex ~= targetclassindex)