[Python] How to change the learning rate of an optimizer at any given moment (no LR schedule)?

Discussão em 'Python' iniciado por Stack, Novembro 28, 2025.

  1. Stack

    Stack Membro Participativo

    Is it possible in PyTorch to change the learning rate of the optimizer in the middle of training dynamically (I don't want to define a learning rate schedule beforehand)?

    So let's say I have an optimizer:

    optim = torch.optim.SGD(model.parameters(), lr=0.01)


    Now due to some tests which I perform during training, I realize my learning rate is too high so I want to change it to say 0.001. There doesn't seem to be a method optim.set_lr(0.001) but is there some way to do this?

    Continue reading...

Compartilhe esta Página