Skip to main content

Atalaya is a logger for pytorch.

Project description

Atalaya

This framework provides a logger for pytorch models, it allows you to save the parameters, the state of the network, the state of the optimizer and allows also to save and visualize your data using tensorboardX or visdom.

Install

$ pip install atalaya

Example

An example is provided here.

Launch the example doing :

$ ./run.sh

An example of logs produced by the logger are given in the logs folder of the example.

Usage

Init

from atalaya import Logger

logger = Logger(
    name="exp",         # name of the logger
    path="logs",        # path to logs
    verbose=True,       # logger in verbose mode
)

# by default Logger uses no grapher
# you can setup it by specifying if you want visdom or tensorboardX
logger = Logger(
    name="exp",         # name of the logger
    path="logs",        # path to logs
    verbose=True,       # logger in verbose mode
    grapher="visdom",
    server="http://localhost",
    port=8097,
    username="user",    # if needed for visdom
    password="pwd",     # if needed for visdom
)

# your code here
...

# to close the logger
logger.close()

Log Information

# logs information in console and in log file.
logger.info("your", "information", "here", "like", "a", "print")

# same as logger.info but for warning messages
logger.warning("your warning")

Store your Parameters

# save your parameters into a json file
logger.add_parameters(args)

# load the parameters froma previous experiment
logger.restore_parameters(path_to_folder)

Store and Restore (models and optimizers)

  1. Add the model (or optimizer or whatever that has a state_dict in pytorch)

    Before starting storing or restoring objects you need to add them to the logger:

        logger.add("model", model)
        logger.add("optimizer", optimizer)
    
  2. Store the model

    In training loop we can add this method, it allows us to save checkpoints, and the best model.

    • The parameter valid_loss is simply the parameter to know when to save the best. It looks if the new valid_loss is less than the value keep by the logger as lower if it's the case save as best and update the value keep in memory.
    • The parameter save_every specify how often to save a checkpoint during training.
    • overwrite specify if we want to overwrite the last checkpoint to keep only the last one or if we want to keep them all (saves a model per epoch --> DANGEROUS)
        logger.store(valid_loss, save_every=1, overwrite=True)
    
  3. Restore the model To restore the best after taining simply do

        logger.restore(best=True)
    

    To restore a checkpoint from another exp :

        logger.restore(folder=path_to_folder)
    

    To restore the best from another exp :

        logger.restore(folder=path_to_folder, best=True)
    

Grapher

Some examples of grapher methods.

logger.add_scalar("train_mse", scalar_value, global_step=None, save_csv=True)

logger.add_text("tag", "your text here")

# values for each batch size at a given epoch
values = {
    "mse": [10, 9, 8, 7],
    "acc": [0.3, 0.5, 0.55, 0.6]
}
logger.register_plots(values, epoch, "train", apply_mean=True, save_csv=True, info=True)

Project details


Download files

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

Files for atalaya, version 0.1.5.4
Filename, size File type Python version Upload date Hashes
Filename, size atalaya-0.1.5.4-py3-none-any.whl (13.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size atalaya-0.1.5.4.tar.gz (23.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page