Code Monkey home page Code Monkey logo

dllogger's Introduction

DLLogger for Python

DLLogger - minimal logging tool

This project emerged from the need for a unified logging schema for Deep Learning Example modules. It provides a simple, extensible, and intuitive logging capabilities with API trimmed to an absolute minimum.

Table Of Contents

Installation

To install DLLogger, run (separate commands):

pip install git+https://github.com/NVIDIA/dllogger#egg=dllogger

Quick Start Guide

To start using DLLogger, add the following two lines of code to your DL training script:

from dllogger import StdOutBackend, JSONStreamBackend, Verbosity
import dllogger as DLLogger

DLLogger.init(backends=[
    StdOutBackend(Verbosity.DEFAULT),
    JSONStreamBackend(Verbosity.VERBOSE, "log.json"),
])

To log data, call DLLogger.log(step=<TRAINING_STEP>, data=<DATA>, verbosity=<VERBOSITY>)

Where:

  • <TRAINING_STEP> can be any number/string/tuple which would indicate where are we in the training process.

  • Use step="PARAMETER" for script parameters (everything that is needed to reproduce the result).

  • Use a tuple of numbers to indicate the training progress, for example:

    • step=tuple(epoch_number, iteration_number, validation_iteration_number) for a validation_iteration_number in a validation that happens after iteration iteration_number of epoch epoch_number

    • step=tuple(epoch_number,) for a summary of epoch epoch_number

    • step=tuple() for a summary of the entire training

  • <DATA> should be a dictionary with metric names as keys and metric values as values.

To log metric metadata, for example, unit, description, ordering, and format, call DLLogger.metadata(metric_name, metric_metadata) where metric_metadata is a dictionary.

Backends can use the metadata information for logging purposes, for example, StdOutBackend uses the format and unit fields to format its output.

The log is automatically saved on the exit of the Python process (with exception of processes killed with SIGKILL). To flush the log file before training ends, run:

DLLogger.flush()

For usage examples, refer to the examples/dllogger_example.py and examples/dllogger_singleton_example.py files.

Available backends overview

DLLogger can use multiple backends for logging, for example, with one logging call, the logged data can be saved or printed in multiple formats.

StdOutBackend

A vanilla backend that holds no buffers; and that prints the provided values to stdout.

StdOutBackend(verbosity, step_format=..., metric_format=...)

Where:

  • step_format is a function that formats step in the DLLogger.log call.

  • metric_format is a function that formats a metric name and value given its metadata

For more information, see the default_*_format functions in the dllogger/logger.py script.

For example output, refer to the examples/stdout.txt file.

JSONStreamBackend

This backend saves JSON formatted lines into a file, adding time stamps for each line.

JsonBackend(verbosity, file_name)

For example output, refer to the examples/dummy_resnet_log.json file.

Advanced usage

By default, DLLogger takes advantage of the singleton pattern. It is possible to obtain a logger instance without referencing the DLLogger global instance, for example, to create multiple and different logs from one script.

from dllogger import Logger
logger = Logger(backends=BACKEND_LIST)

dllogger's People

Contributors

jan-golda avatar asulecki avatar mmarcinkiewicz avatar shakandrew avatar satakuma 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.