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

4 ビュー (過去 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 件のコメント
prabakaran jayaraman
prabakaran jayaraman 2015 年 6 月 26 日
thanks greg. how to get ∑ (Xi * IW). if i am having 3 inputs and iw as 20 X 3 matrix
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 Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by