Why are the results of forward and predict very different in deep learning?
Show older comments
When I use the "dlnetwork" type deep neural network model to make predictions, the results of the two functions are very different, except that using the predict function will freeze the batchNormalizationLayer and dropout layers.While forward does not freeze the parameters, he is the forward transfer function used in the training phase.


From the two pictures above, there are orders of magnitude difference in the output of the previous 10 results. Where does the problem appear?
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com
Accepted Answer
More Answers (3)
vaibhav mishra
on 30 Jun 2020
0 votes
Hi there,
In my opinion you are using BatchNorm in training and not in testing, so how can you expect to get the same results from both. You need to use batchnorm in testing also with the same parameters as training.
1 Comment
xingxingcui
on 7 Jul 2020
Edited: xingxingcui
on 7 Jul 2020
xingxingcui
on 12 Jul 2020
0 votes
Luc VIGNAUD
on 29 Jun 2021
0 votes
Thank you for raising this question. I did observe this issue playing with GANs and the difference comes indeed from the batchNorm. I ended using InstanceNorm instead but the question remains and should be answered by the matlab team ...
1 Comment
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!