Git Product home page Git Product logo

custom-fastai-callbacks's Introduction

Fast-Callbacks

Custom Callbacks to extend the Fastai library's functionality
(Feel free to contribute to this project in whatever ways you like !!)


This package contains generalized callbacks that be used by anyone using the fastai library (V1).
Currently there are 5 callbacks here that I found useful when training models over huge datasets or when the models are too big to increase the batch size over a small number. I plan to keep adding callbacks to this repository as and when I make them for my own use. I'm still and always learning and welcome any changes and feedback to my project.
  1. GradientAccumulator: Accumulates gradients over N iterations before performing an optimizer step.
    This implementation does not solve the subtle issue of BatchNorm layers during gradient accumulation. We simply skip over optimizer steps for N iterations and accumulate gradients before doing the actual step.
    Usage:
    from callbacks import GradientAccumulator
    accumulator = partial(GradientAccumulator, num_iterations=4)
    learn = create_cnn(data, models.resnet18, callback_fns = [accumulator])
  1. SaveEveryNIterations: Saves model after every N iterations
    We save all models with the same name as otherwise the models could use up too much memory. Usage:
    from callbacks import SaveEveryNIterations
    saver_callback = partial(SaveEveryNIterations, num_iterations=100, 
                                              save_name="saved_every_100_iterations")
    learn = create_cnn(data, models.resnet18, callback_fns = [saver_callback])
  1. StopAfterNIterations : Stops model after N iterations.
    Usage:
    from callbacks import StopAfterNIterations
    stopper = partial(StopAfterNIterations, num_iterations = 17)
    learn = create_cnn(data, models.resnet18, callback_fns = [stopper])
  1. ShowResultsEveryNIterations: Shows model results after every N iterations
    Usage:
    from callbacks import ShowResutsEveryNIterations
    results_callback = partial(ShowResutsEveryNIterations, num_iterations=100)
    learn = create_cnn(data, models.resnet18, callback_fns = [results_callback])
  1. SkipNIterations: Skips first N iterations while training
    Usage:
    from callbacks import SkipNIterations
    skipper = partial(SkipNIterations, num_iterations=100)
    learn = create_cnn(data, models.resnet18, callback_fns = [skipper])

custom-fastai-callbacks's People

Contributors

akashpalrecha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.