Code Monkey home page Code Monkey logo

adafactor-pytorch's Introduction

Forked and customized (experimental) πŸ§ͺ

This branch comes with a new custom experimental feature: a piecewise constant learning rate schedule. As the whole point of using adafactor is to maintain precision while reducing memory usage, I won't be submitting this branch as pull request. This is for academic purposes.

How to πŸ“”

The learning rate schedule can be controlled by two new parameters: lr_decay_step and lr_decay_factor.

Why this feature? πŸ’‘

These changes aim to provide more flexibility and control over the learning rate during training while keeping the core benefits of the AdaFactor optimizer.

Elaborate? πŸ“

This enhancement allows the learning rate to decrease by a specified factor at predefined epochs, which can potentially improve training performance and convergence. Adjusting the learning rate at key points during training (based on empirical or theoretical insights) can lead to better convergence behavior. This is particularly useful in scenarios where the default learning rate schedule might not be optimal.

Any caution? πŸ€”

Keep the rates within reasonable bounds.

Since it's an orthogonal feature, it adds value without compromising the optimizer’s core benefit πŸ‘. In other words, the piecewise constant learning rate won't interfere with the memory efficiency. Also changing the learning rate according to a predefined schedule does not impact the numerical stability of the algorithm, as long as the chosen rates are within reasonable bounds as mentioned above.

adafactor-pytorch

A pytorch realization of adafactor (https://arxiv.org/pdf/1804.04235.pdf )

Notes

1)Factorization works on any dimension. When dimension of weight tensor is higher than 2, it will be reshaped to 2D. For turning off this feature just change this lines ( if len(shape) > 2: return False, True ) in _check_shape

2)Weights decay was moved to proper position according (https://arxiv.org/abs/1711.05101 )

Parameters description:

lr - learning rate can be scalar or function, in second case relative step size is using.

beta1, beta2 - is also can be scalar or functions, in first case algorithm works as AMSGrad. Setting beta1 to zero is turning off moments updates.

non_constant_decay - boolean, has effect if betas are scalars. If True using functions for betas (from section 7.1)

enable_factorization - boolean. Factorization works on 2D weights.

clipping_threshold - scalar. Threshold value for update clipping (from section 6)

adafactor-pytorch's People

Contributors

deadat0m avatar andy-leezard avatar

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.