stared / livelossplot

Live training loss plot in Jupyter Notebook for Keras, PyTorch and others
https://p.migdal.pl/livelossplot
MIT License
1.29k stars 143 forks source link

Custom Message (Batch Size, etc) #111

Closed ginward closed 4 years ago

ginward commented 4 years ago

🚀 Feature

Is it possible to add a feature that can send a custom message to display below the plots? For example, I am doing some hyper parameter search and it would be nice to display the current batch size, learning rate, etc.

Thanks!

stared commented 4 years ago

@ginward Yes, it can be done. For that, you need to write a custom output

from livelossplot import PlotLosses
from livelossplot.outputs import MatplotlibPlot, ExtramaPrinter, BaseOutput

class YourPrinter(BaseOutput):
    def __init__(self):
        self.iteration = 0

    def send(self, logger):
        self.iteration += 1
        print(f"{self.iteration}")

plotlosses = PlotLosses(outputs=[MatplotlibPlot(), ExtramaPrinter(), YourPrinter()])

See https://github.com/stared/livelossplot/blob/master/livelossplot/outputs/extrema_printer.py for inspiration.

For numeric values, you can also add batch size and the learning rate to logged variables.

Let me know it if helps.

ginward commented 4 years ago

Ok thanks!