The ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler’ occurs when there is a mismatch between your PyTorch version and the code you are running.
To fix the ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler’ error, update it using pip command: pip install –upgrade torch.
You can check your current PyTorch version by running the following commands in a Python environment:
import torch print(torch.__version__)
If you use conda, you can use this command to upgrade pytorch: conda update pytorch.
If the problem persists after updating PyTorch, it could be that SAVE_STATE_WARNING is unavailable in the version you are using or the name has been changed or removed.
In that case, you may need to modify the code to work with the current version of PyTorch or find an alternative way to achieve the desired functionality.
Read more here: Source link