Git Product home page Git Product logo

pytorch-polynomial-lr-decay's Introduction

pytorch-polynomial-lr-decay

Polynomial Learning Rate Decay Scheduler for PyTorch

This scheduler is frequently used in many DL paper. But there is no official implementation in PyTorch. So I propose this code.

Install

$ pip install git+https://github.com/cmpark0126/pytorch-polynomial-lr-decay.git

Usage

from torch_poly_lr_decay import PolynomialLRDecay

scheduler_poly_lr_decay = PolynomialLRDecay(optim, max_decay_steps=100, end_learning_rate=0.0001, power=2.0)

for epoch in range(train_epoch):
    scheduler_poly_lr_decay.step()     # you can handle step as epoch number
    ...

or

from torch_poly_lr_decay import PolynomialLRDecay

scheduler_poly_lr_decay = PolynomialLRDecay(optim, max_decay_steps=100, end_learning_rate=0.0001, power=2.0)

...

for batch_idx, (inputs, targets) in enumerate(trainloader):
    scheduler_poly_lr_decay.step()     # also, you can handle step as each iter number

pytorch-polynomial-lr-decay's People

Contributors

cmpark0126 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorch-polynomial-lr-decay's Issues

Thank you for Code

Hi @cmpark0126 ,

Thank you for your code. I did not find any button to comment. Therefore, just created an Issue to thank you.

Kind regards,

self.t_step is not found

Thank you for your code!
the param 'self.t_step' is not defined in current file and base-class, can you fix it?

Suggestion : Pytorch compatibility get_last_lr

Hello,

first of all thank you very much for your implementation. I noticed a small "incompatibility" when using the scheduler. Since some update, Pytorch recommends using .get_last_lr() over .get_lr(). In their code they've added a warning.

def get_lr(self):
    if not self._get_lr_called_within_step:
        warnings.warn("To get the last learning rate computed by the scheduler, "
                      "please use `get_last_lr()`.", UserWarning)

When plugging your scheduler into existing (newer) code bases, this raises an error as some use get_last_lr(). A quick fix would be adding the following to your code:

    def get_last_lr(self):
        return self.get_lr()

Best Regards,
L

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.