pytorch model(torch.nn.Module)笔记

参考:『PyTorch』第十四弹_torch.nn.Module类属性

官网:https://ptorch.com/docs/1/torch-nn

model.eval() # 将本层及子层的training设定为False   在测试阶段,dropout什么都不做

model.train() # 将本层及子层的training设定为True

BatchNorm与Dropout层在训练阶段和测试阶段中采取的策略不同,通过判断training值来决定前向传播策略。

原文地址:https://www.cnblogs.com/cekong/p/11157579.html