Prev: Can someone help me writing this script file on matlab program?
Next: Accessing individual contents of cell array for large amount of cells
From: Fernando Henrique on 9 Apr 2010 16:18 Hello, 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);
From: Greg Heath on 9 Apr 2010 19:46 On Apr 9, 4:18 pm, "Fernando Henrique" <fernandoh...(a)gmail.com> wrote: > Hello, > > 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 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
From: Fernando Henrique on 12 Apr 2010 08:46 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). 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 <heath(a)alumni.brown.edu> wrote in message <610901f7-804b-4fea-aff7-236a8bc6bb0d(a)x7g2000vbc.googlegroups.com>... > On Apr 9, 4:18 pm, "Fernando Henrique" <fernandoh...(a)gmail.com> wrote: > > Hello, > > > > 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 > > 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
From: Greg Heath on 13 Apr 2010 04:29 CORRECTED FOR THE HEINOUS SIN OF TOP-POSTING! On Apr 12, 8:46 am, "Fernando Henrique" <fernandoh...(a)gmail.com> wrote: > Greg Heath <he...(a)alumni.brown.edu> wrote in message <610901f7-804b-4fea-aff7-236a8bc6b...(a)x7g2000vbc.googlegroups.com>... > > On Apr 9, 4:18 pm, "Fernando Henrique" <fernandoh...(a)gmail.com> wrote: > > > Hello, > > > > 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 > > > 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? > 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
From: Fernando Henrique on 13 Apr 2010 07:32
I am dividing it, as in: 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 <heath(a)alumni.brown.edu> wrote in message <5d1c324d-e956-4be9-8e2e-280b93fbdd9a(a)r18g2000yqd.googlegroups.com>... > > CORRECTED FOR THE HEINOUS SIN OF TOP-POSTING! > > On Apr 12, 8:46 am, "Fernando Henrique" <fernandoh...(a)gmail.com> > wrote: > > Greg Heath <he...(a)alumni.brown.edu> wrote in message <610901f7-804b-4fea-aff7-236a8bc6b...(a)x7g2000vbc.googlegroups.com>... > > > On Apr 9, 4:18 pm, "Fernando Henrique" <fernandoh...(a)gmail.com> wrote: > > > > Hello, > > > > > > 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 > > > > > 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? > > 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 > > |