Matlab - Neural Network Training

I am working on a two-layer backpropagation neural network. It is assumed that NN will receive its data from the vector 20001x17, which contains the following information in each row:

. The first 16 cells contain integers from 0 to 15, which act as variables to help us determine which of the 26 letters of the alphabet we want to express when viewing these variables. For example, a sequence of 16 values ​​below is intended to denote the letter A: [2 8 4 5 2 7 5 3 1 6 0 8 2 7 2 7].

- The 17th cell contains a number from 1 to 26, representing the letter of the desired alphabet. 1 means A, 2 means B, etc.

The output NN level consists of 26 outputs. Each time NN is supplied to an input similar to that described above, it should output a 1x26 vector containing zeros in all but one cell, which corresponds to the letter that the input values ​​should represent. for example, the output [1 0 0 ... 0] will be the letter A, while [0 0 0 ... 1] will be the letter Z.

Some things that are important before I present the code: I need to use the traingdm function, and the number of the hidden layer is fixed (for now) at 21.

Trying to create the above concept, I wrote the following matlab code:

%%%%%%%%
%Start of code%
%%%%%%%%

%
%Initialize the input and target vectors
%
p = zeros(16,20001);
t = zeros(26,20001);

%
%Fill the input and training vectors from the dataset provided
%
for i=2:20001
    for k=1:16
        p(k,i-1) = data(i,k);
    end
    t(data(i,17),i-1) = 1;
end

net = newff(minmax(p),[21 26],{'logsig' 'logsig'},'traingdm');

y1 = sim(net,p);

net.trainParam.epochs = 200;
net.trainParam.show = 1;
net.trainParam.goal = 0.1;
net.trainParam.lr = 0.8;
net.trainParam.mc = 0.2;
net.divideFcn = 'dividerand';
net.divideParam.trainRatio = 0.7;
net.divideParam.testRatio = 0.2;
net.divideParam.valRatio = 0.1;

%[pn,ps] = mapminmax(p);
%[tn,ts] = mapminmax(t);

net = init(net);
[net,tr] = train(net,p,t);

y2 = sim(net,pn);

%%%%%%%%
%End of code%
%%%%%%%%

Now to my problem: I want my outputs to be as described, namely, each column of the vector y2, for example, should be a letter representation. My code does not do this. Instead, he gave results that vary greatly from 0 to 1, values ​​from 0.1 to 0.9.

: - , , ? , / , , NN?

.

+5
4

. - , 0 1.

, , - - , .

, y2 , . :

[dummy, I]=max(y2);

I - , .

+2

y2, 26 , , y2 :

.2
.5
.15
.15

50% , B ( 4 ).



== ==

NN 26 . , NN , 1x26 , , . , [1 0 0... 0] A, [0 0 0... 1] Z.

0,1 .
0 1 , logsig . , 0 1, .
0 1 , , 0,04 0,9, [0,9,0,04,..., 0,04] ​​ A.


:
. , , McGraw-Hill, 1997, p114-115

+1
  • hardlin fcn .
    • trainlm trainrp .
    • , for , . , .
    • mapminmax .
+1

, : .

  • . "" ? , . : , "a" 1, "b" 2, "c" 3, , "a" "b", "c" ( , ). , 26 - , , .
  • , 0, 1, . max , , , back-prop. , softmax, . , . , - (, , ), .

See David McCake's tutorial for a nice introduction to neural networks that will help you understand probabilistic relationships. Take a look at this article by the Geoff Hinton group , which describes the context prediction task for the next character for details about the correct representation and activation / function of activity (although beware of their method is non-trivial and uses a recursive network with a different learning method).

0
source

All Articles