【问题标题】:How to check if a model is in train or eval mode in Pytorch?如何在 Pytorch 中检查模型是处于训练模式还是评估模式?
【发布时间】:2021-03-28 08:55:56
【问题描述】:

如何从模型中检查它当前是否处于训练或评估模式?

【问题讨论】:

    标签: python machine-learning deep-learning pytorch


    【解决方案1】:

    来自the Pytorch forum,稍作调整:

    使用

    if self.training:
        # it's in train mode
    else:
        # it's in eval mode
    

    获得堆栈溢出答案总是比查看论坛更好。

    Explanation about the modes

    【讨论】:

      猜你喜欢
      • 2022-07-05
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-13
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      相关资源
      最近更新 更多