Code Monkey home page Code Monkey logo

keras-tqdm's Introduction

keras-tqdm

Keras integration with TQDM progress bars.

  • Keras is an awesome machine learning library for Theano or TensorFlow.
  • TQDM is a progress bar library with good support for nested loops and Jupyter/IPython notebooks.

Key features

  • TQDM supports nested progress bars. If you have Keras fit and predict loops within an outer TQDM loop, the nested loops will display properly.
  • TQDM supports Jupyter/IPython notebooks.
  • TQDM looks great!

TQDMNotebookCallback with leave_inner=False (default)

Keras TQDM leave_inner=False

TQDMNotebookCallback with leave_inner=True

Keras TQDM leave_inner=True

TQDMCallback for command-line scripts

Keras TQDM CLI

Installation

Stable release

pip install keras-tqdm

Development release

pip install git+https://github.com/bstriner/keras-tqdm.git --upgrade --no-deps

Development mode (changes to source take effect without reinstalling)

git clone https://github.com/bstriner/keras-tqdm.git
cd keras-tqdm
python setup.py develop

Basic usage

It's very easy to use Keras TQDM. The only required change is to remove default messages (verbose=0) and add a callback to model.fit. The rest happens automatically! For Jupyter Notebook required code modification is as simple as:

from keras_tqdm import TQDMNotebookCallback
# keras, model definition...
model.fit(X_train, Y_train, verbose=0, callbacks=[TQDMNotebookCallback()])

For plain text mode (e.g. for Python run from command line)

from keras_tqdm import TQDMCallback
# keras, model definition...
model.fit(X_train, Y_train, verbose=0, callbacks=[TQDMCallback()])

Advanced usage

Use keras_tqdm to utilize TQDM progress bars for Keras fit loops. keras_tqdm loops can be nested inside TQDM loops to display nested progress bars (although you can use them inside ordinary for loops as well). Set verbose=0 to suppress the default progress bar.

from keras_tqdm import TQDMCallback
from tqdm import tqdm
for model in tqdm(models, desc="Training several models"):
    model.fit(x, y, verbose=0, callbacks=[TQDMCallback()])

For IPython and Jupyter notebook TQDMNotebookCallback instead of TQDMCallback. Use tqdm_notebook in your own code instead of tqdm. Formatting is controlled by python format strings. The default metric_format is "{name}: {value:0.3f}". For example, use TQDMCallback(metric_format="{name}: {value:0.6f}") for 6 decimal points or {name}: {value:e} for scientific notation.

Questions?

Please feel free to submit PRs and issues. Comments, questions, and requests are welcome. If you need more control, subclass TQDMCallback and override the tqdm function.

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.