Explicit equation did not give the result same as the output value obtained from ANN model

2 views (last 30 days)
I developed my ANN model using tangsig activation function for the hidden layer and purelin for the output layer. I have saved the model beforehand so that weight and bias will not change after I run the model again. I obtain the weight and bias from the network by using following commands:
InputWeight = LTnet2.IW{1,1}
LayerWeight = LTnet2.LW{2,1}
InputBias = LTnet2.b{1,1}
LayerBias = LTnet2.b{2,1}
I used the weights and bias to form the explicit equations where:
Layer 1 : y1 = tanh(X*InputWeight+InputBias)
Layer 2 : y2 = y1*LayerWeight+LayerBias
However, after I developed the explicit equations and want to test the new data with the equations to predict the output, the value is different from what is predicted from the model. Can anyone advise me what is the problem?

Accepted Answer

Ayush Aniket
Ayush Aniket on 29 Nov 2023
Hi Shing Mei Chiew,
As per my understanding you are getting different output for your data through explicit equations for your ANN model than predicted by the model. The reason behind this is that the "net” object returned by the “feedforwardnetneural network function or ANN model in MATLAB uses pre-processing and post-processing functions to process the input and output data.
To achieve the same output through explicit equations, you can add these lines to your code:
normalized_IO = mapminmax('apply', IO, LTnet2.inputs{1}.processSettings{1}); %we are applying the same pre-processing as in the feedforwardnet
output = mapminmax('reverse', LTpredicted, LTnet2.outputs{2}.processSettings{1});%we are applying the same post-processing as in the feedforwardnet
To read more about the process functions please refer to the following documentation page:
Hope it helps.

More Answers (0)

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!