1

AttributeError: module 'torch' has no attribute 'set_grad_enabled'

Traceback (most recent call last): File "/home/thaqafi/PycharmProjects/transfer_learning/tutorial_transfer.py", line 280, in

model_ft = train_model(model_ft, criterion, optimizer_ft, exp_lr_scheduler, num_epochs=25)

File "/home/thaqafi/PycharmProjects/transfer_learning/tutorial_transfer.py", line 179, in train_model with torch.set_grad_enabled(True):

AttributeError: module 'torch' has no attribute 'set_grad_enabled'

using source code form Pytorch webiste.

http://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html

1 Answer 1

1

As far as I know this feature was not available before version 0.4.0, so probably you are using a version lower than 0.4.0 (e.g. 0.3.1.).

Try updating PyTorch to version 0.4.0. if possible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.