Skip to main content

Log TensorBoard events without Tensorflow

Project description

tensorboard_logger

https://img.shields.io/pypi/v/tensorboard_logger.svg https://img.shields.io/travis/TeamHG-Memex/tensorboard_logger.svg

Log TensorBoard events without TensorFlow

TensorBoard is a visualization tool (not this project, it’s a part of TensorFlow framework) that makes it easy to check training progress, compare between different runs, and has lots of other cool features.

tensorboard_example.png

tensorboard_logger library allows to write TensorBoard events without TensorFlow:

from tensorboard_logger import configure, log_value

configure("runs/run-1234")

for step in range(1000):
    v1, v2 = do_stuff()
    log_value('v1', v1, step)
    log_value('v2', v2, step)

Note: if you are already using TensorFlow in your project, you probably don’t need this library.

Installation

TensorFlow is required only for viewing logged events: please check installation guide on the official site (you probably want a CPU-only version).

tensorboard_logger can be installed with pip:

pip install tensorboard_logger

Usage

You can either use default logger with tensorboard_logger.configure and tensorboard_logger.log_value functions, or use tensorboard_logger.Logger class.

This library can be used to log numerical values of some variables in TensorBoard format, so you can use TensorBoard to visualize how they changed, and compare same variables between different runs. Log file is written into a directory, so you need a separate directory for each run (you can place other logs or output files you use in the same directory). Directories from different runs you wish to compare should have the same parent (there can be other files or directories with the same parent, TensorBoard will figure out which directories contain logs).

Apart from variable names and their values, another important thing is the step: this must be an integer that represents some increasing step - it can be a step in training or some other number. The values are ordered by step in TensorBoard, although you can view them ordered by time or relative step too.

A simple usage example:

from tensorboard_logger import configure, log_value

configure("runs/run-1234", flush_secs=5)

for step in range(1000):
    v1, v2 = do_stuff()
    log_value('v1', v1, step)
    log_value('v2', v2, step)

You can start TensorBoard right away:

tensorboard --logdir runs

And go check the metrics to TensorBoard UI at http://localhost:6006 (note that it binds to 0.0.0.0 by default). Metrics are refreshed on switch to browser tab, and there is also a refresh button at the top right.

Runtime overhead rather large, about 0.1 - 0.2 ms for a single value logged (so about 5,000 - 10,000 operations per second).

API

tensorboard_logger.configure(logdir, flush_secs=2)

Configure logging: a file will be written to logdir, and flushed every flush_secs. NOTE: right now file is flushed after each event written.

tensorboard_logger.log_value(name, value, step=None)

Log new value for given name on given step. value should be a real number (it will be converted to float), and name should be a string (it will be converted to a valid TensorFlow summary name). step should be an non-negative integer, and is used for visualization: you can log several different variables on one step, but should not log different values of the same variable on the same step (this is not checked). You can also omit step entirely.

tensorboard_logger.Logger

A class for writing logs in a directory. Use it if default logger used in two above functions is not enough for you (e.g. you want to log into several different directories, or don’t like global variables). Constructor has the same signature as tensorboard_logger.configure, and it has a single log_value method with the same signature as tensorboard_logger.log_value.

Development

Compiling python protobuf files:

protoc --python_out . tensorboard_logger/tf_protobuf/summary.proto
protoc --python_out . tensorboard_logger/tf_protobuf/event.proto

License

MIT license

History

0.0.3 (2016-11-17)

  • Fix PyPI packaging

0.0.2 (2016-11-03)

  • TensorFlow is no longer required (#1)

  • Travis build is fixed (#2)

0.0.1 (2016-11-01)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorboard_logger-0.0.3.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

tensorboard_logger-0.0.3-py2.py3-none-any.whl (15.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tensorboard_logger-0.0.3.tar.gz.

File metadata

File hashes

Hashes for tensorboard_logger-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d120c35bb538107f12f168cb7e478e6aa3166dd656842730d2cdbdb5e89f52ac
MD5 f1766796cc5aea037e5aa726880b0b53
BLAKE2b-256 0e279741fddd0aeabaf3ffe9447c7e92237230a27938d6313dc77de4d5f8b6c4

See more details on using hashes here.

File details

Details for the file tensorboard_logger-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tensorboard_logger-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b4151e996674e3845043371a2e84fef91fb5fb343733a80eb11875978f7a5787
MD5 7c38113182e501b487737ef606f8f179
BLAKE2b-256 b3c4f2976c88e02577370d1202a74bd67f73f5e471d4d72cc82545c41c7853bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page