Skip to main content

Easy TensorFlow Logging

Note: NOT compatible with TensorFlow 2! A pull request fixing this would be very gratefully accepted :)

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.

Metadata

Release files for easy-tf-log 1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-tf-log 1.12
File Size Uploaded Provenance Actions
easy_tf_log-1.12.tar.gz 3.9 kB Without provenance Details for easy_tf_log-1.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easy-tf-log 1.12
File Interpreter ABI Platform Actions
easy_tf_log-1.12-py3-none-any.whl Python 3 none any Details for easy_tf_log-1.12-py3-none-any.whl

Total release size: 8.6 kB

Release files / easy_tf_log-1.12.tar.gz

Download URL easy_tf_log-1.12.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6899bd1a62298d590812dc952f43c631173230db1839f4b17df23a8e833eb528
BLAKE2b-256 checksum
How to use checksums
61a97701a25ff286bc9227516f714f1c1f6aa702eae3a3a8a1f35143c3302a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

Release files / easy_tf_log-1.12-py3-none-any.whl

Download URL easy_tf_log-1.12-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
226ccbe532eaa2ac6d734fbaeaff419f543a64c7beef8928a37b9daa93e123e0
BLAKE2b-256 checksum
How to use checksums
acd8d18b16a4fb5326604705c586510cc373a6e787d9ed1adaea19c66c7a4d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

Security for easy-tf-log 1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page