how to calculate the output of neural network manually using input data and weights.

9 次查看(过去 30 天)
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?

采纳的回答

Greg Heath
Greg Heath 2015-6-25
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 个评论
Greg Heath
Greg Heath 2015-6-28
编辑:Greg Heath 2015-6-28
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

请先登录,再进行评论。

更多回答(1 个)

Amir Qolami
Amir Qolami 2020-4-12
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

类别

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