从Pytorch论坛中,稍作调整: 使用 if self.training: # it's in train mode else: # it's in eval mode 与其查看论坛,有一个堆栈溢出的答案总是更好的选择。 关于模式的解释