weight and bias values i get from trained neural network is mistake?

1 view (last 30 days)
Hi, i try to get the weight and bias from the neural network that i train.
ActFunc_Hid and ActFunc_Out depends on any activation function i set on hidden and outer layer.
However, when i trained the neural network, i test it again by output = sim(net, a), where a is new input. the shown output is not the same as what i calculate manually based on the weight and bias value got from the trained neural network.
Is there any mistake in my code?
net=newff(input, output, 1,{ActFunc_hid ActFunc_Out});
[net tr]=train(net,input,output);
w1 = net.IW{1}
w2 = net.LW{2}
b1 = net.b{1}
b2 = net.b{2}

Accepted Answer

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH on 4 Dec 2019
It is not the same because Matlab does a normalization procedure of the variables so if you want to do it manually it would be like this:
xoffset = net.inputs {1} .processSettings {1} .xoffset;
gain = net.inputs {1} .processSettings {1} .gain;
ymin = net.inputs {1} .processSettings {1} .ymin;
y1 = bsxfun (@ times, bsxfun (@ minus, x, xoffset), gain);
y1 = bsxfun (@ plus, y1, ymin);
y1 is the true entrance to the neural network
  2 Comments
Alessia Li Noce
Alessia Li Noce on 9 Apr 2021
Hi,sorry for bring it up after all this time, for the output is the same procedure? I'm doing also a manually implementation and I want to replicate the pre/post processing of newff, which use the mapminmax

Sign in to comment.

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows 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!