'ExponentialLR' object has no attribute 'zero_grad'
时间: 2023-10-16 18:07:44 浏览: 36
The error you are seeing suggests that you are trying to call the `zero_grad()` method on an object of the `ExponentialLR` class in PyTorch. However, the `ExponentialLR` class does not have a `zero_grad()` method, so this results in an attribute error.
The `zero_grad()` method is typically used to clear the gradients of all the parameters of a model, so it is usually called on an optimizer object rather than a learning rate scheduler object like `ExponentialLR`.
To fix this error, you should check where you are calling `zero_grad()` and make sure that you are calling it on the correct object. If you need to clear the gradients of your model, you should call `zero_grad()` on the optimizer object instead.