GithubHelp home page GithubHelp logo

xiaoanshi / accum_optimizer_for_keras Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bojone/accum_optimizer_for_keras

0.0 1.0 0.0 24 KB

wrapping a keras optimizer to implement gradient accumulation

Python 100.00%

accum_optimizer_for_keras's Introduction

[中文|English]

为Keras实现梯度累积版优化器

特点

继承Optimizer类,包装原有优化器,实现梯度累积功能。能够无缝对接原有优化器,不需要重写优化器。

用法

如下例子等价于直接使用batch_size=100的Adam优化器(代价就是你跑了10个epoch,实际上只相当于batch_size=100跑了1个epoch):

opt = AccumOptimizer(Adam(), 10) # 10是累积步数
model.compile(loss='mse', optimizer=opt)
model.fit(x_train, y_train, epochs=10, batch_size=10)

读者也可以直接跑一跑mnist_mlp_example.py

链接

https://kexue.fm/archives/6794

交流

QQ交流群:67729435,微信群请加机器人微信号spaces_ac_cn

accum_optimizer_for_keras's People

Contributors

bojone 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.