How to get the equation for trained Neural Network Toolbox
4 views (last 30 days)
Show older comments
I have trained my neural network and extracted the weights.
Using the weights, I constructed the equation to get the output value, however, I'm not getting the same value as the value predicted from Matlab. I wonder where I go wrong:
weights = cell(3,1)
biases = net.b
x1 = [1.5527; -1.2526; -1.1460]
w1 = weights{1} % 20x3
b1 = biases{1} % 20x1
intermediate = w1*x1 + b1
y1_0_y1_19 = tansig(intermediate); % Layer 1
x2 = y1_0_y1_19; % 20x1
w2 = weights{2}; % 10x20
b2 = biases{2}; % 10x1
intermediate2 = w2*x2 + b2 % 10 x 1
y2_0_y2_10 = tansig(intermediate2); % Layer 2
x3 = y2_0_y2_10; % 10 x 1
w3 = weights{3}; % 1x10
b3 = biases{3}; % 1x1
intermediate3 = w3*x3 + b3 % 1 x 1
y3 = intermediate3; % Layer 3
However the y3 that I got is different from the output of the network when I run the following net(x1).
Can someone tell where I went wrong in my formulation to the output value y3?
0 Comments
Accepted Answer
Steven Lord
on 9 Oct 2019
You haven't shown your network so I can't be certain but I'm guessing you forgot the pre- and post-processing steps.
2 Comments
More Answers (0)
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!