How to get the transfer function equation for the implemented neural network

1 view (last 30 days)
I have implemented neural network of two layers and hidden layer size is 3. for both layers activation function is purelin. When I calculate theoretically output of neural network it is not matching with output provided by neural network of matalab. Plz let me know where i am doing wrong. Thanks

Accepted Answer

Greg Heath
Greg Heath on 9 Nov 2016
You have to obtain xsettings and tsettings from x and t.
Then apply them to x2 and t2.
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (1)

Greg Heath
Greg Heath on 14 Sep 2016
Edited: Greg Heath on 14 Sep 2016
I misplaced my turban and crystal ball. Therefore I cannot tell you where you have gone wrong.
OH! It just occurred to me!
1. Why don't you post your code?
2. Include any comments and error messages that result when you try
to run your code.
3. Include the results of running your code on data in the help
and doc documentation. e.g.,
help fitnet
doc fitnet
Thank you for formally accepting my answer
Greg
PS. Have you included
a. the normalization of input and target
b. The denormalization of the output
Hope this helps.
Greg
  6 Comments
jalpa shah
jalpa shah on 5 Nov 2016
Dear Greg, I have tried your tutorial code and pasted the code which i have tried. In code for lines (1), (2) and (3), when I put X and t instead of x2 and t2 then ya from equation and y are matching. But when I put x2 and t2 then yn and ya both are coming as 0.678 from equations and y2 from simulation of net coming as 4.3997. Means y2 output from simulation does not match with ya calculated from equation.
can you please tell me why its happening like this? your help will be appreciated. thanks
x= [9.71771231870987,9.83342660442415,9.97628374728129]
t= [4.39863796358009,4.69563206044186,4.91324004903954]
x2= [9.62398374728130]
t2= [4.09380849773465]
net = fitnet;
rng( 4151941 )
[ net tr y e ] = train( net, x, t );
y2=sim(net,x2);
% THE ANALYTIC I/O RELATIONSHIP
xn = mapminmax(x2); %.....(1)
[ tn, tsettings ] = mapminmax(t2); %....(2)
[p,N]= size(x2); %......(3)
b1 = net.b{1} ; % [ H 1 ]
IW = net.IW{ 1 ,1 }; % [ H I ]
b2 = net.b{2} ; % [ O 1 ]
LW = net.LW{ 2, 1 }; % [ O H ]
whos b1 IW b2 LW
B1 = repmat( b1 , 1, N ) ;
B2 = repmat( b2 , 1, N ) ; % For O > 1
yn = B2 + LW * tanh( B1 + IW * xn );
ya = mapminmax.reverse(yn,tsettings);
end

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!