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)
-
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)
-
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)
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file atalaya-0.1.5.4.tar.gz
.
File metadata
- Download URL: atalaya-0.1.5.4.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c0c5967fde9bd532da767159709619d7f14ccec6d1dfa56c10aee9cb4f7fae9 |
|
MD5 | f7e5fff40bc63a2e65d776a9c89745e6 |
|
BLAKE2b-256 | b0531dc7c172191eb6d6d28ef306b363fce06c9eda9e65f93d5095132fe2bd59 |
File details
Details for the file atalaya-0.1.5.4-py3-none-any.whl
.
File metadata
- Download URL: atalaya-0.1.5.4-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4ea7cb00493e18d339b4654070d9e248f6ab3253c8d11b23e2448f5b2219d00 |
|
MD5 | 04ca1ef6237f4ee31178d211ab14c2f1 |
|
BLAKE2b-256 | c8488b816ebf3413fa55d9c8a76b2716abd4a6ed9e6c2563ac6b9c0bc2976b25 |