pythonloggingpytorch-lightning

How to disable logging from PyTorch-Lightning logger?


Logger in PyTorch-Lightning prints information about the model to be trained (or evaluated) and the progress during the training,

However, in my case I would like to hide all messages from the logger in order not to flood the output in Jupyter Notebook.

I've looked into the API of the Trainer class on the official docs page https://pytorch-lightning.readthedocs.io/en/latest/common/trainer.html#trainer-flags and it seems like there is no option to turn off the messages from the logger.

There is a parameter log_every_n_steps which can be set to big value, but nevertheless, the logging result after each epoch is displayed.

How can one disable the logging?


Solution

  • I am assuming that two things are particularly bothering you in terms of flooding output stream:

    One, The "weight summary":

      | Name | Type   | Params
    --------------------------------
    0 | l1   | Linear | 100 K 
    1 | l2   | Linear | 1.3 K 
    --------------------------------
    ...
    

    Second, the progress bar:

    Epoch 0:  74%|███████████   | 642/1874 [00:02<00:05, 233.59it/s, loss=0.85, v_num=wxln]
    

    PyTorch Lightning provided very clear and elegant solutions for turning them off: Trainer(progress_bar_refresh_rate=0) for turning off progress bar and Trainer(weights_summary=None) for turning off weight summary.