How can I manually evaluate my data to validate my neural network?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to validate the data which my neural network is generating, but when I follow the steps in the doc, I receive a different answer than what is generated by my neural network.
Akzeptierte Antwort
MathWorks Support Team
am 27 Jun. 2009
To replicate the calculations of a neural network, you must:
1) Pre-process the inputs.
2) Perform the calculations using the correct weights, biases, transfer functions, and connections.
3) Post-process the outputs.
The following example replicates the output of a 2 layer feed-forward backpropogation network.
inputs = [0 1 2 3 4 5 6 7 8 9 10];
% inputs = inputs + .1 *rand(size(inputs));
targets = [0 1 2 3 4 3 2 1 2 3 4];
% Create a network with 1 neuron in the first layer
net=newff(inputs,targets,1,{'tansig','tansig'},'trainlm');
% Train the network
net = init(net);
net.trainParam.epochs = 100;
[net,tr,out]=train(net,inputs,targets);
%Simulate the network with the inputs
[Y,Pf,Af,E,perf] = sim(net,inputs);
%Calculate output manually:
% Pre-process the data
for iii = 1:numel(net.inputs{1}.processFcns)
inputs = feval( net.inputs{1}.processFcns{iii}, ...
'apply', inputs, net.inputs{1}.processSettings{iii} );
end
% Calculate the network response
a1 = tansig(net.IW{1,1}*inputs + net.b{1});
Yc = tansig(net.LW{2,1}*a1 + net.b{2});
% Post-process the data
for iii = 1:numel(net.outputs{2}.processFcns)
Yc = feval( net.outputs{2}.processFcns{iii}, ...
'reverse', Yc, net.outputs{2}.processSettings{iii} );
end
close all
% View results
[Y' Yc']
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Define Shallow Neural Network Architectures finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!