with torch.no_grad()用处


1、可以减少内存使用

2、训练集训练好模型后,在验证集这里使用with torch.no_grad(),训练集则不会计算梯度值,然后并不会改变模型的参数,只是看了训练的效果。

相关