MATLAB: How to get the equation for trained Neural Network Toolbox

Deep Learning Toolboxneural network

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} % 20×3
b1 = biases{1} % 20×1
intermediate = w1*x1 + b1
y1_0_y1_19 = tansig(intermediate); % Layer 1
x2 = y1_0_y1_19; % 20×1
w2 = weights{2}; % 10×20
b2 = biases{2}; % 10×1
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}; % 1×10
b3 = biases{3}; % 1×1
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?

Best Answer

You haven't shown your network so I can't be certain but I'm guessing you forgot the pre- and post-processing steps.