• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy TensorFlow logging for quick prototypes

Easy TensorFlow Logging

Build Status

Note: This is mainly designed for TensorFlow 1; the logging API in TensorFlow 2 is significantly easier than in TensorFlow 1. This module is compatible with TensorFlow 2, but some features may not work with eager execution.

Are you prototyping something and want to be able to magically graph some value without going through all the usual steps to set up TensorFlow logging properly?

easy_tf_log is a simple module to do just that.

from easy_tf_log import tflog

then you can do

for i in range(10):
    tflog('really_interesting_variable_name', i)

and you'll find a directory logs that you can point TensorBoard to

$ tensorboard --logdir logs

to get

See demo.py for a full demo.

Based on logging code from OpenAI's baselines.

Installation

pip install easy-tf-log

Note that TensorFlow must be installed separately.

Documentation

easy-tf-log supports logging using either a global logger or an instantiated logger object.

The global logger is good for very quick prototypes, but for anything more complicated, you'll probably want to instantiate your own Logger object.

Global logger

  • easy_tf_log.tflog(key, value, step=None)
    • Logs value (int or float) under the name key (string).
    • step (int) sets the step associated with value explicitly. If not specified, the step will increment on each call.
  • easy_tf_log.set_dir(log_dir)
    • Sets the global logger to log to the specified directory.
    • log_dir can be an absolute or a relative path.
  • easy_tf_log.set_writer(writer)
    • Sets the global logger to log using the specified tf.summary.FileWriter instance.

By default (i.e. if set_dir is not called), the global logger logs to a logs directory automatically created in the working directory.

Logger object

  • logger = easy_tf_log.Logger(log_dir=None, writer=None)
    • Create a Logger.
    • log_dir: an absolute of relative path specifying the directory to log to.
    • writer: an existing tf.summary.FileWriter instance to use for logging.
    • If neither log_dir nor writer are specified, the logger will log to a logs directory in the working directory. If both are specified, the constructor will raise a ValueError.
  • logger.log_key_value(key, value, step=None)
    • See tflog.
  • logger.log_list_stats(key, values_list)
    • Log the minimum, maximum, mean, and standard deviation of values_list (a list of ints or floats).
  • logger.measure_rate(key, value)
    • Log the rate at which value (int or float) changes per second.
    • The first call internally stores the time of the first value; the second call logs the change between the second value and the first value divided by the time between the calls; etc.
  • logger.set_dir(log_dir)
    • See easy_tf_log.set_dir(log_dir).
  • logger.set_writer(writer)
    • See easy_tf_log.set_writer(writer).
  • logger.close()
    • Flush logs and close the log file handle.

More Repositories

1

learning-from-human-preferences

Reproduction of OpenAI and DeepMind's "Deep Reinforcement Learning from Human Preferences"
Python
305
star
2

javascript-karplus-strong

JavaScript/Web Audio implementation of Karplus-Strong guitar synthesis
JavaScript
284
star
3

distributed_tensorflow_gentle_introduction

Jupyter notebook running through basic examples of Distributed TensorFlow
Jupyter Notebook
71
star
4

ultra_ping

Measure UDP packet latency
Python
67
star
5

tbplot

Plot TensorBoard graphs fast
Python
51
star
6

tensorflow-rl-pong

Pong AI trained using policy gradient-based reinforcement learning
Python
51
star
7

musical-pattern-recognition-in-spiking-neural-networks

Differentiate notes using a spiking neural network
Python
48
star
8

sanger-machine-learning-workshop

Code for machine learning workshop given to Sanger Systems group
Python
40
star
9

humble-gumbel

Jupyter notebook on Gumbel-max and Gumbel-softmax tricks
Jupyter Notebook
39
star
10

ocd-a3c

TensorFlow implementation of asynchronous advantage actor-critic (A3C)
Python
39
star
11

gym-moving-dot

A simple moving dot environment for OpenAI Gym to test reinforcement learning algorithms
Python
22
star
12

tensorflow-pos-tagger

Part-of-speech tagger implemented using a feedforward network in TensorFlow
Python
14
star
13

mpi-vagrant

Bring up a cluster of VMs in Vagrant suitable for testing MPI
13
star
14

dotfiles

Vim Script
11
star
15

tf-sac

TensorFlow implementation of Soft Actor-Critic
Python
10
star
16

tensorboard_screenshot

Automatically take a screenshot of TensorBoard graphs using Headless Chrome
JavaScript
6
star
17

tensor-typing-exploration

Examples of code and stubs where tensor shape typing would be useful
5
star
18

sqs-alerts

Pop up macOS alerts from an AWS Simple Queue Service
Python
5
star
19

tmuxprocess

Redirect I/O from Python processes to different tmux windows
Python
5
star
20

docker-cfengine-servers

Git hooks for spawning CFEngine policy servers
Shell
5
star
21

tf-resnet

TensorFlow/Keras ResNet on CIFAR-10
Python
1
star
22

tf-dqn

TensorFlow implementation of Deep Q-learning
Python
1
star
23

rightermove

Python
1
star