how to calculate the output of neural network manually using input data and weights.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
prabakaran jayaraman
am 19 Jun. 2015
Beantwortet: Amir Qolami
am 12 Apr. 2020
i am having ann program with 3 inputs and one output. i am using back propagation and feed forward network. the activation functions are tansig and purelin. no of layer is 2 and no of neuron in hidden layer is 20. i want to calculate the output of network manually using the input and weights(iw,lw,b) i need an equation to find the output. can you help me?
Akzeptierte Antwort
Greg Heath
am 25 Jun. 2015
When I-dimensional "I"nput x and O-dimensional "O"utput target t are normalized via the default mapminmax (or mapstd),the relationship between the normalized input and output is
yn = repmat( b2, O, N ) + LW * tanh( repmat( b1 , I, N ) + IW * xn);
Thank you for formally accepting my answer
Greg
2 Kommentare
Greg Heath
am 28 Jun. 2015
Bearbeitet: Greg Heath
am 28 Jun. 2015
IW does not act on the original weights. It acts on the normalized weights. The default normalization documentation is
help mapminmax
doc mapminmax.
Search for examples using a subset of
greg xsettings tsettings
Greg
Weitere Antworten (1)
Amir Qolami
am 12 Apr. 2020
This works for any number of hidden layers and neurons;
function output = NET(net,inputs)
w = cellfun(@transpose,[net.IW{1},net.LW(2:size(net.LW,1)+1:end)],'UniformOutput',false);
b = cellfun(@transpose,net.b','UniformOutput',false);
tf = cellfun(@(x)x.transferFcn,net.layers','UniformOutput',false);
%%mapminmax on inputs
if strcmp(net.Inputs{1}.processFcns{:},'mapminmax')
xoffset = net.Inputs{1}.processSettings{1}.xoffset;
gain = net.Inputs{1}.processSettings{1}.gain;
ymin = net.Inputs{1}.processSettings{1}.ymin;
In0 = bsxfun(@plus,bsxfun(@times,bsxfun(@minus,inputs,xoffset),gain),ymin);
else
In0 = inputs;
end
In = cell(1,length(w)); Out = In;
In{1} = In0'*w{1}+b{1};
Out{1} = eval([tf{1},'(In{1})']);
for i=2:length(w)
In{i} = Out{i-1}*w{i}+b{i};
Out{i} = eval([tf{i},'(In{',num2str(i),'})']);
end
%%reverse mapminmax on outputs
if strcmp(net.Outputs{end}.processFcns{:},'mapminmax')
gain = net.outputs{end}.processSettings{:}.gain;
ymin = net.outputs{end}.processSettings{:}.ymin;
xoffset = net.outputs{end}.processSettings{:}.xoffset;
output = bsxfun(@plus,bsxfun(@rdivide,bsxfun(@minus,Out{end},ymin),gain),xoffset);
else
output = Out{end};
end
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Define Shallow Neural Network Architectures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!