Coder Social home page Coder Social logo

kristpapadopoulos / keras-stochastic-weight-averaging Goto Github PK

View Code? Open in Web Editor NEW
55.0 3.0 22.0 8 KB

Keras callback function for stochastic weight averaging

Python 100.00%
keras callback callback-functions stochasticweightaveraging weightaveraging ensemble weights keras-implementations stochastic-weight-averaging keras-callback

keras-stochastic-weight-averaging's Introduction

Stochastic Weight Averaging with Keras callback function

Stochastic Weight Averaging following paper Averaging Weights Leads to Wider Optima and Better Generalization

The file swa.py contains an implementation for stochastic weight averaging (SWA) with a constant learning rate for a user defined amount of epochs.

Callback is instantiated with filename for saving the final weights of the model after SWA and the number of epochs to average.

Example

The total number of training epochs 150, SWA to start from epoch 140 to average last 10 epochs.

from swa import SWA

# specify number of training epochs
number_of_epochs = 150

# specify the start epoch of stochastic weight averaging
swa = SWA(140, filepath = None)

# call SWA during model fitting
model.fit(..., callbacks = [swa])

keras-stochastic-weight-averaging's People

Contributors

53rt avatar kristpapadopoulos 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

Watchers

 avatar  avatar  avatar

keras-stochastic-weight-averaging's Issues

Which optimizer should I use?

Thanks for your code, but I am curious that which optimizer should I use? Can I use adam? Or I must use SGD? Thank you.

Would you like to give us an example to use swa callback?

Thank you so much for your code.
It will be great if you would like to upload an example to show how to use your callback. If I use learning_rate_schedular, may I combine your saw together? Because you said that your learning rate is a constant. Many thanks.

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.