Code Monkey home page Code Monkey logo

seml_logger's Introduction

SEML Logger

This package contains small utility code to enable easy logging to TensorBoardX for experiments managed via seml.

Installation

pip install git+https://github.com/n-gao/seml_logger.git

Usage

Initialization

from sacred import Experiment
from seml_logger import automain, Logger

ex = Experiment()

...

def naming_fn(dataset, **_):
    # This function shall return a name for the tensorboard run
    # you may also simply use a timestamp instead but you can also
    # grab any of the main parameters to construct a fitting name.
    return dataset

@automain(ex, naming_fn)
def main(..., dataset='MNIST', logger: Logger):
    ...

Automatic logging

In addition to the manual logs, seml_logger also dumps all parameters in a file called config.json within the Tensorboard directory. The config file is also logged in Tensorboard directly via the Text functionality.

If the experiment crashes, i.e., the code returns with an exception or an error code != 0, the stacktrace is also logged via Tensorboard for easy access.

Finally, the results of the experiments are stored via pickle in results.pickle within the logging directory.

Tensorboard logging

The Logger class automatically redirects attributes to tensorboardX.SummaryWriter, so you can directly use the logger as

for i in range(10):
    logger.add_scalar(i, global_step=i)

Additionally, several utility functions are implemented to log dictionaries of parameters directly.

File logging

To store parameters or intermediate variables we use numpy.save and numpy.savez. You may store arrays in the tensorboard directory via logger.store_array or logger.store_dict.

HDF5 logging

To log lots of numerical data, HDF5 presents a nicely accessible way of storing such data. To create an HDF5 dataset simply call

logger.create_dataset('name', shape=(...), ...)

The interface is identical to h5py.File.create_dataset. Further, after creating datasets, you may access them directly from the logger via indexing

# works after creating the `name` dataset.
logger['name']

seml_logger's People

Contributors

n-gao avatar

Stargazers

Gev avatar Chendi Qian avatar

Watchers

 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.