I have trained a neural network using 'nprtool', which is supposed to use "sigmoid hidden and output neurons". I am trying to use the results of this training (weights and biases) to implement a neural network from scratch. Unfortunately, I cannot get the right results. Could anyone point what I am doing wrong? The code follows below.
Thanks in advance,
Fernando H.
%Neural Network training
numHiddenNeurons = 40;
net = newpr(P,T,numHiddenNeurons); %The network has two inputs and one output
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
[net,tr] = train(net,P,T);
%Neural Network implementation
inputsInput=[A;B];
weightsInput=net.IW{1,1};
weightsLayer=net.LW{2,1};
biasesInput=net.B{1,1};
biasesLayer=net.B{2,1};
inputsLayer=tansig(weightsInput*inputsInput+biasesInput);
Output=tansig(weightsLayer*inputsLayer+biasesLayer);
sizeP = size(P) % ?
sizeT = size(T) % ?
Does H = 40 make sense for the size of the data base?
Search
greg heath Neq Nw
> net.divideParam.trainRatio = 70/100;
> net.divideParam.valRatio = 15/100;
> net.divideParam.testRatio = 15/100;
> [net,tr] = train(net,P,T);
>
> %Neural Network implementation
> inputsInput=[A;B];
size(A) % ?
size(B) % ?
> weightsInput=net.IW{1,1};
> weightsLayer=net.LW{2,1};
> biasesInput=net.B{1,1};
> biasesLayer=net.B{2,1};
> inputsLayer=tansig(weightsInput*inputsInput+biasesInput);
> Output=tansig(weightsLayer*inputsLayer+biasesLayer);
Please explain EXACTLY what you mean by
"Unfortunately, I cannot get the right results."
Do you get the right results when you use SIM?
Hope this helps.
Greg
I'm using the neural network as a classifier, so by right results I mean results that correspond to reality (when I use an input vector with known output). I think the number of neurons makes sense, as the network results are OK when I use SIM.
Thank you for your time,
Fernando H
Greg Heath <he...@alumni.brown.edu> wrote in message <610901f7-804b-4fea...@x7g2000vbc.googlegroups.com>...
On Apr 12, 8:46 am, "Fernando Henrique" <fernandoh...@gmail.com>
wrote:
> Greg Heath <he...@alumni.brown.edu> wrote in message <610901f7-804b-4fea-aff7-236a8bc6b...@x7g2000vbc.googlegroups.com>...
> size(P) = 2 10000
> size(T) = 1 10000
> size(A) = 1 1
> size(B) = 1 1
>
> I'm using the neural network as a classifier, so by right results I mean results > that correspond to reality (when I use an input vector with known output).
Considering the size of your training set you are probably OK.
However, it is better to partition the data into training, validation
and test sets. So that you can select training parameters and
predict future performance by using nontraining data. In addition,
you can reduce training times by not using an excessive amount
of training data.
I think the number of neurons makes sense, as the network results
are OK when I use SIM.
On nontraining data?
> Thank you for your time,
> Fernando H
You are welcome.
Hope this helps.
Greg
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
And yes, I'm testing with data outside the training set. The network performs correctly with SIM. I really think the problem is in the implementation "from scratch", but from the definition, I can't find what's wrong:
inputsInput=[A;B];
weightsInput=net.IW{1,1};
weightsLayer=net.LW{2,1};
biasesInput=net.B{1,1};
biasesLayer=net.B{2,1};
inputsLayer=tansig(weightsInput*inputsInput+biasesInput);
Output=tansig(weightsLayer*inputsLayer+biasesLayer);
Thank you,
Fernando Henrique
Greg Heath <he...@alumni.brown.edu> wrote in message <5d1c324d-e956-4be9...@r18g2000yqd.googlegroups.com>...
Check algorithm defaults.
In particular, mapminmax and 'purelin'
Hope this helps.
Greg