Package: loggerml
LoggerML - Rich machine learning logger in the consoleLog your Machine Learning training in the console in a beautiful way usingrich✨ with useful information but with
minimal code.DocumentationhereInstallationIn a new virtual environment, install simply the package viapipy:pipinstallloggermlThis package is supported on Linux, macOS and Windows.
It is also supported on Jupyter Notebooks.Quick startMinimal usageIntegrate the LogML logger in your training loops! For instance for 4 epochs
and 20 batches per epoch:importtimefromlogmlimportLoggerlogger=Logger(n_epochs=4,n_batches=20)for_inrange(4):for_inlogger.tqdm(range(20)):time.sleep(0.1)# Simulate a training step# Log whatever you want (int, float, str, bool):logger.log({'loss':0.54321256,'accuracy':0.85244777,'loss name':'MSE','improve baseline':True,})Yields:)Note that the expected remaining time of the overall train is displayed as well as
the one for the epoch. The logger also provides also the possibility to average the
logged values over an epoch or a full training.Save the logsIn Linux you can useteeto save the logs in a file and display them in the console.
However you need to useunbufferto keep the style:unbufferpythonmain.py--color=auto|teeoutput.logSeeherefor details.Advanced usageNow you can add a validation logger, customize the logger with your own styles
and colors, compute the average of some values over batch, add a dynamic
message at each batch, update the value only every some batches and more!At initialization you can set default configuration for the logger that will be
eventually overwritten by the configuration passed to thelogmethod.An example with more features:train_logger=Logger(n_epochs=2,n_batches=20,log_interval=2,name='Training',name_style='dark_orange',styles='yellow',# Default style for all valuessizes={'accuracy':4},# only 4 characters for 'accuracy'average=['loss'],# 'loss' will be averaged over the current epochbold_keys=True,# Bold the keys)val_logger=Logger(n_epochs=2,n_batches=10,name='Validation',name_style='cyan',styles='blue',bold_keys=True,show_time=False,# Remove the time bar)for_inrange(2):train_logger.new_epoch()# Manually declare a new epochfor_inrange(20):train_logger.new_batch()# Manually declare a new batchtime.sleep(0.1)# Overwrite the default style for "loss" and add a messagetrain_logger.log({'loss':0.54321256,'accuracy':85.244777},styles={'loss':'italic red'},message="Training is going well?\nYes!",)val_logger.new_epoch()for_inrange(10):val_logger.new_batch()time.sleep(0.1)val_logger.log({'val loss':0.65422135,'val accuracy':81.2658775})val_logger.detach()# End the live display to print something else afterYields:Don't know the number of batches in advance?If you don't have the number of batches in advance, you can initialize the logger
withn_batches=None. Only the available information will be displayed. For instance
with the configuration of the first example:The progress bar is replaced by a cyclic animation. The eta times are not know at the
first epoch but was estimated after the second epoch.Note that if you useLogger.tqdm(dataset)and the dataset has a length, the number of
batches will be automatically set to the length of the dataset.How to contributeFordevelopment, install the package dynamically and dev requirements with:pipinstall-e.
pipinstall-rrequirements-dev.txtEveryone can contribute to LogML, and we value everyone’s contributions.
Please see ourcontributing guidelinesfor more information 🤗TodoTo do:Done:Allow multiple logs on the same batchFinalize tests for 1.0.0 major releaseAdd docs sections: comparison with tqdm and how to use mean_vals
(with exp tracker)Use regex forstyles,sizesandaveragekeysBe compatible with notebooksGet back the cursor when interrupting the traininglogger.tqdm()feature (used liketqdm.tqdm)Doc with SphinxBe compatible with Windows and MacsManage a validation loop (then multiple loggers)Add color customization for message, epoch/batch number and timeLicenseCopyright (C) 2023  Valentin GolditéThis program is free software: you can redistribute it and/or modify it under the
terms of theMIT License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.This project is free to use for COMMERCIAL USE, MODIFICATION, DISTRIBUTION and
PRIVATE USE as long as the original license is include as well as this copy
right notice at the top of the modified files.