Why am i getting zero neurons in output layer of pattern net?

3 views (last 30 days)
i m using patternnet for satellite image classification.NO training is done and performance shown is also zero when i try to train my neural network. when i run command view(net), it shows me zero neurons in output layer. what is the reason?

Accepted Answer

Greg Heath
Greg Heath on 15 Mar 2014
Unlike the obsolete functions newfit, newpr, newff, etc, that are created from x and t, the current functions fitnet, patternet, feedforwardnet etc, are NOT created with input nodes, output nodes, input weights, layer weights or output biases; ONLY hidden nodes and input biases. The rest are assigned only after x and t are introduced via the functions configure or train. The command init(net) is ineffective at this stage. For example, paste into the command line WITHOUT THE ENDING SEMICOLON
clear all, clc
net = patternnet
Nw = net.numWeightElements
biases = net.biases
b = net.b
inputWeights = net.inputWeights
IW = net.IW
layerweights = net.layerweights
LW = net.LW
Now repeat the last 7 commands after
1. init(net);
and
2. Either
net = configure(net, x, t)
or
[net tr y e ] = train(net, x, t)
Obviously, syntax was changed to accommodate future changes in the NNToolbx. You will have to ask the MATLAB staff for details.
Hope this helps.
Thank you for formally accepting my answer
Greg
  2 Comments
saima zia
saima zia on 15 Mar 2014
Edited: saima zia on 15 Mar 2014
thank u so much for being so helpful. but it is not working. in fact my input matrix (x) is 2321748x1 single and training matrix (t) is also same size. according to my knowledge the no of neurons in output layer are same as size of output, so as in my case the size of output is 2321748 so this much no of neurons in output layer cannot be possible. if u suggest, i can post my code.
saima zia
saima zia on 15 Mar 2014
here is my code: it is not training and no of neurons shown for output layer are zero. img = imread('c:\Matlab\ndvi\ndvi_2007025.tif');
img=img(:);
w = img(img>0.5 | img==0.5); %to separat wheat pixels with ndvi value>=.5
col_size = size(w, 1);
ones_row = ones(col_size,1)*1; % wheat pixels are targeted as 1 w=[w, ones_row];
f=img(img<0.5 & img>=0.3 ); % to separate fodder pixels with ndvi<.5 and>.3
col_size = size(f, 1);
twos_row = ones(col_size,1)*2; % fodder pixels targeted by 2
f=[f, twos_row]
other=img(img<0.3); % to separare remaining pixels with ndvi< 0.3
col_size = size(other, 1);
threes_row = ones(col_size,1)*3; % targeted by 3
other=[other, threes_row]
P=[w; f; other]
training=P(:,1); % training is 2321748x1 matrix
group=P(:,2); % group is 2321748x1 matrix
net = patternnet(10);
[net tr y e ] = train(net,training,group);
view(net);
y = net(img);

Sign in to comment.

More Answers (1)

Greg Heath
Greg Heath on 16 Mar 2014
>thank u so much for being so helpful. but it is not working. in fact my input matrix (x) is 2321748x1 single and training matrix (t) is also same size.
I don't really understand what you are doing. With N I-dimensional-input/O-dimensional-target pairs, the input and target matrices have the size
[ I N ] = size(x)
[ O N ] = size(t)
with N >> max(I,O).
The node topology of the corresponding net with I input fan-in units, H hidden neurons and O output neurons is is I-H-O.
For a classifier with c mutually exclusive classes/categories, O=c and the columns of t should be columns from the unit matrix eye(c). The row index of the single 1 is the index of the corresponding class. The correspondence between the unit vectors and integer class indices is given by
target = ind2vec(classindices)
classindices = vec2ind(target)
If your data are images, you need to extract an I-dimensional feature vector from each image.
For examples, see the targets of the MATLAB classification example data sets using
help nndatasets
doc nndatasets
Also see the documentation and example for patternnet
help patternnet
doc patternnet
Then search for my examples in the NEWSGROUP and ANSWERS using
greg patternnet
>according to my knowledge the no of neurons in output layer are same as size of output, so as in my case the size of output is 2321748 so this much no of neurons in output layer cannot be possible. if u suggest, i can post my code.
Please don't.
You need to reformat your input and target matrices as described above. For example
[x,t] = simpleclass_dataset;
whos % 1000 examples of 4 classes in 2 dimensions
t=t % No semicolon
How many images do you have? N
How many classes/categories? c
How many features do you extract from each image? I
Where did you get the 2 million-plus number ? It is probably a factor of 1000 more than a reasonable value. So let's get this straight before proceeding further.

Community Treasure Hunt

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

Start Hunting!