Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the inaccuracy of pytorch test results

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "pytorch test results are not accurate how to solve", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "pytorch test results are not accurate how to solve" article.

When we encounter inaccurate training results, we may need to check to see if there are BN or Dropout layers in the defined Model class, if any

Then you need to add a line of code before testing: # model is the instantiated model object model = model.eval ()

Means to convert the model to evaluation mode, which eliminates the interference of BN and Dropout to the test.

Because BN and Dropout are different in training and testing:

For BN, mini-batch is usually used in training, so the mean and std in each batch are roughly the same; while the test phase is often the input of a single image, there is no concept of mini-batch. Therefore, after changing model to eval mode, the parameters of BN are fixed and the previously trained global mean and std are used.

For Dropout, the hidden layer neurons multiply the probability P first and then activate it in the training stage, while in the test phase, the neurons are activated first, and the output of each hidden layer neuron is then multiplied by the probability P.

The above is about the content of the article "how to solve the inaccurate pytorch test results". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report