Home > other >  Matlab BP neural network, the custom error connection weights
Matlab BP neural network, the custom error connection weights

Time:10-11

CLC
The clear

% training data
Train_data=https://bbs.csdn.net/topics/csvread (' credit_train. CSV);
Train_input=train_data (:, departure) ';
Train_target=train_data (:, 24) ';


% test dataTest_data=https://bbs.csdn.net/topics/csvread (' credit_test. CSV);
Test_input=test_data (:, departure) ';
Test_target=test_data (:, 24) ';



Net=newff (train_input train_target, 6 3 [11] and {' tansig 'and' purelin '}, 'traingd');
Net %="train" (.net, train_input, train_target);
Net=init (net);
Net. TrainParam. Epochs=2000;
Net. TrainParam. Lr=0.1;
Net. TrainParam. Goal=0.000001;

% the weights between input layer to the hidden layer
Net. Iw={1, 1} [0 0 0 0 0 0 0 0 0 0 0;...
1.1781 0 0 0 0 0 0 0 0 0-2.754; .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
1 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
0-0.636-1.7340 0 0 0 0 0 0 0 0; .
1 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0; 1.8744 .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0-1.359 0 0 0 0 0; .
3.3477 0 0 0 0 0 0 0 0 0 1; .
2.4885 0 0 0 0 0 0 0 0 0 0; .
5.6864 to 2.9390 0 0 0 0 0 0 0 0 0; .
0 0 0 0-5.311-0.356 0 0 0 0 0; .
1 0 0 0 0 0 0 0 0 0 0; .
0 0 0 0 0 0 0 0 0 0; 2.2566 .
0 0 0 0 0 0 0 0 0 0; 3.8345 .
0 0 0 0 0 0 0 0 0 0 0];

% input layer to the first threshold of hidden layer
Net. B={1} [0.6656, 1.061, 2.140; 0; 0; 1.2018; 0; 0; 0.6554; 5.3281; 0];


% the first hidden layer and the second the weights between hidden layer
Net. Lw={2, 1} [1.6499 0 0 0 0 0;...
1.590 0 0 0 0 0; .
0.5048 0 0 0 0 0; .
1 0 0 0 0 0; .
2.412 0 0 0 0 0; .
4.0544 0 0 0 0 0; .
1 0 0 0 0 0; .
5.7816 0 0 0 0 0; .
4.0871 0 0 0 0 0; .
2.2716 0 0 0 0 0; .
0 0 0 0 0, 1];

% of the first hidden layer to the second hidden layer threshold
Net. B={2} [3.057-0.116; 0; -; 0; 3.2617; 0];

% the second hidden layer to the third the weights between hidden layer
Net. Lw={3, 2}
[1.6016 0 0;...1.404 0 0; .
0.194 0 0; .
6.7859 0 0; .
0.7696 0 0; .
0, 0, 1];
% the second hidden layer to the third threshold of hidden layer
Net. B={3} [0.317, 4.2467, 0];

% the weights between hidden layer to output layer 3
Net. Lw={4, 3} [1.7153, 2.329, 3.0611];
Net. {4} b=0.9570;

% network training
Net="train" (.net, input_train, train_target);

Y=sim (.net, test_input);

Y (y<0.5)=0;
Y (y>=0.5)=1;


% accuracy
Rightnumber=0;
For I=1: size (test_target, 2)
If y (I)==test_target (I)
Rightnumber=rightnumber + 1;
End
End
Rightratio=rightnumber/size (test_target, 2) * 100;

Sprintf (=% 0.2 f ' 'test accuracy, rightratio)

The code above,
Run times wrong: the Error using the network/subsasgn> Network_subsasgn (line 528)
Net. IW {1, 1} must be a 11 - by - 23 matrix.

The Error in the network/subsasgn (line 13)
Net=network_subsasgn (.net, subscripts, v, netname);

The Error in FNTNN (line 24)
Net. Iw={1, 1} [0 0 0 0 0 0 0 0 0 0 0;...


Where does weight definition format is wrong or wrong, net. Iw {1, 1} read only the first row, why didn't the rest of the,
Matlab was used for the first time, according to the data of online writing, a great god, please teach, thank you,

  • Related