Can' t import torch.optim.lr_scheduler

When import torch.optim.lr_scheduler in PyCharm, it shows that AttributeError: module ‘torch.optim’ has no attribute ‘lr_scheduler’. But in the Pytorch’ s documents, there is torch.optim.lr_scheduler. So why torch.optim.lr_scheduler can’ t import?

Hi, which version of PyTorch do you use? I think you see the doc for the master branch but use 0.12.

Thank you! You are right. If I want to use torch.optim.lr_scheduler, how to set up the corresponding version of PyTorch?

Currently the latest version is 0.12 which you use. So if you like to use the latest PyTorch, I think install from source is the only way.

Okay, thank you very much!

Check your local package, if necessary, add this line to initialize lr_scheduler. I find my pip-package doesn’t have this line.

i found my pip-package also doesn’t have this line. can i just add this line to my init.py ? how solve this problem?? thx

I am using the the pytorch_version ‘0.1.12’ but getting the same error.
One more thing is I am working in virtual environment.
Is this is the problem with respect to virtual environment?
Thank you in advance

You are using a very old PyTorch version. Have a look at the website for the install instructions for the latest version.