Name 'torch' is not defined while doing `torch.load`


I am doing torch.load to load my model (I know it’s not recommended but I don’t have another way)

But then I got the following error

35 x =, 1)
NameError: name 'torch' is not defined

Which is very strange, the training went smoothly, the model code is accessible.
How I can resolve this issue?

Maybe try restarting your Python kernel runtime and perform import torch again.


Hi Vas, have you managed to figure something out? Facing a similar issue.