Filter löschen
Filter löschen

Issue in calculating targets from neural network model

2 Ansichten (letzte 30 Tage)
Hi,
I have trained a neural network model and saved it for predicting new inputs for future. To verify the targets predicted by model manually, i have taken the network weights and biases and estimated the targets accordingly. But the values obtained from this approach and directly from the model is varying. Could anyone help me with this please. I have attached the manual calculation procedure here.
inputvector = X_train(1,:)'
z_hidden = bestNetwork.IW{1}*inputvector+bestNetwork.b{1}
a_hidden = 1./(1+exp(-z_hidden)) % I have used logistic sigmoid function for input and hidden layer
z_output = bestNetwork.LW{2,1}*a_hidden+bestNetwork.b{2}
a_output = (2/(1+exp(-2*z_output)))-1 % I have used hyperbolic tangent function for hidden and output layer
d = bestNetwork(inputvector)
The value of 'a_output' and 'd' has different value. Please help me in resolving this issue.

Akzeptierte Antwort

Shivansh
Shivansh am 8 Nov. 2023
Hi Srinivas,
I understand from the description that you are manually calculating the forward pass of your neural network and comparing the output with the output of the trained model.
If the difference in the outputs is not very significant, the discrepancy of the output can be attributed to the numerical precision issues. MATLAB uses double-precision floating-point numbers, which can lead to small differences in calculations due to rounding errors.
There can also be other reasons for the discrepancy in outputs. Here are some things to check:
Activation Functions: You can verify that you are using the correct activation functions for each layer using “bestNetwork.layers{1}.transferFcn” and “bestNetwork.layers{2}.transferFcn“ functions.
Network Architecture: You can verify that your manual calculation matches the architecture of your trained network. You can check the number of layers, the number of neurons in each layer, the connections between the layers, etc.
You can refer to the following link for more information about the properties and functions for the network https://www.mathworks.com/help/deeplearning/ug/neural-network-subobject-properties.html#bss4hk6-99.
I hope this helps!
  1 Kommentar
Srinivas Alagesan
Srinivas Alagesan am 8 Nov. 2023
Hi Shivansh,
Thanks for your response. I have figured it out the reason behind the difference. It's due to normalization settings which I overlooked in the manual calculation.
Anyways, Once thank you so much for your response.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by