【python报错】with torch.no_grad: AttributeError: __enter__

报错:

Traceback (most recent call last):
  File "D:/classify_leaves/classify-leaves/predict.py", line 7, in <module>
    import train
  File "D:\classify_leaves\classify-leaves\train.py", line 145, in <module>
    with torch.no_grad:
AttributeError: __enter__

Process finished with exit code 1

解决办法:
with torch.no_grad():
少加一个括号

你可能感兴趣的:(python,深度学习,开发语言)