How can I manually evaluate my data to validate my neural network?

조회 수: 3 (최근 30일)
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.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
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개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by