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 visualize your data using tensorboardX or visdom.

Install

pip install atalaya

Example

Examples are provided in examples directory, where we simply add the logger to an example of a pytorch implemetation (source) in example_1. In each directory you have also the files created by the logger. There is a directory named logs and one named vizualize. The first one contains the logs of each experiment and the second one the files needed to visualize e.g. in tensorboard.

Init

from atalaya import Logger

logger = Logger()

# by default Logger uses tensorboardX as graher
# you can use visdom by changing the default value
logger = Logger(grapher='visdom')

Parameters

You can add parameters (save directly when addParams is called), you can also load parameters from a previous experiment.

args = parser.parse_args()

# add parameters to the logger
logger.add_parameters(args)

# load from previous experiment
args = logger.restore_parameters(args.path_of_previous_experiment)

Informations

You can log information instead of use print, this way you will see the information in terminal and it will also be logged in train.log file for a later consultation.

logger.info("message to log and print", "like in a print")

# you can also use it for warnings
logger.warning("message")

store and restore (models and optimizers)

To save checkpoints and the best model you need to call save method in traning loop. You can choose with wich frequency to save a checkpoint and if we want to overwrite the previous and keep always the last saved.

# before store, you need to add to the logger all you want to store using the logger.add('name', object) method

logger.add('model', model)
logger.add('optimizer', optimizer)

# and in the training loop
for epoch in epochs:
    ...
    # pay attention it really recomended to keep overwrite=True
    # if not you may have memory problems if e.g. you save your model
    # every epoch and you have 2000 epochs
    logger.store(train_loss, val_loss, save_every=1, overwrite=True)

And after the training you can load the best model and test it or before training you can load from a previous experience.

logger.restore(best=True)
#or
logger.restore(path_to_a_checkpoint)

visualizer

This logger as a wrapper to tensorboardX and visdom. It allows you to better visualize your experiments. By default, for visdom, the server is localhost and the port is 8097. You can change them if you want when you intitialize the Logger.

# to add a scalar
logger.add_scalar('my_scalar', value, epoch)

# to add many scalars in a dictionary
values = {'train_loss':train_loss_values, 'val_loss':val_loss_values}
logger.register_plots(values, epoch, prefix='train', apply_mean=True)

Project details


Download files

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

Source Distribution

atalaya-0.1.3.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

atalaya-0.1.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file atalaya-0.1.3.tar.gz.

File metadata

  • Download URL: atalaya-0.1.3.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for atalaya-0.1.3.tar.gz
Algorithm Hash digest
SHA256 77ec9d773c6a7bcca4efe7df588870492057739f25cb2ca496e4ad428d492634
MD5 2ac69c2160f810639326589569ff17c4
BLAKE2b-256 bb5bed7cd37d07c908cb66e31df61d9980a7ea3926bf72dfa4f42a8b87eb0267

See more details on using hashes here.

File details

Details for the file atalaya-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: atalaya-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for atalaya-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2064bb03c59807dd0f96f119c41b51c257dcfa7479f7eda4b6daf2c4c7580cc3
MD5 d82d764183fe0e777e331de576225a9b
BLAKE2b-256 bd8d0323a9101e2c95a62ed831a470d0f0580d19b624cc799dddc0aee9d0372c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page