Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.1] - 2026-05-05

Internal cleanup pass and a few small breaking removals. For older Python or
older import paths, pin a previous `livelossplot` version.

### Removed

- The `livelossplot.keras` / `livelossplot.tf_keras` / `livelossplot.poutyne` /
`livelossplot.pytorch_ignite` import shortcuts (deprecated since 0.5.0).
Use `livelossplot.inputs.*` or `from livelossplot import PlotLossesKeras` etc.
- `PlotLosses.draw()` (deprecated since 0.5.0). Use `.send()`.

### Changed

- `ExtremaPrinter` parameter `massage_template` renamed to `message_template`.
- `Plot2d` parameter `valiation_data` renamed to `validation_data`.

### Fixed

- Mutable default arguments in `PlotLosses(outputs=...)` and `MatplotlibPlot(extra_plots=...)`.
- `MainLogger.groups = None` now correctly resets to `{}`.
- `ipython` declared as a runtime dependency.

## [0.6.0] - 2026-05-04

### Changed
Expand Down
4 changes: 2 additions & 2 deletions examples/2d_prediction_maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"model = MLP(6)\n",
"\n",
"plot2d = matplotlib_subplots.Plot2d(model, X_train, y_train,\n",
" valiation_data=(X_test, y_test),\n",
" validation_data=(X_test, y_test),\n",
" margin=0.2, h=0.02, device=device)\n",
"plot2d.predict = plot2d._predict_pytorch\n",
"liveloss = PlotLosses(outputs=[plot2d])\n",
Expand Down Expand Up @@ -272,7 +272,7 @@
"model = MLP(3, activation=nn.Sigmoid())\n",
"\n",
"plot2d = matplotlib_subplots.Plot2d(model, X_train, y_train,\n",
" valiation_data=(X_test, y_test),\n",
" validation_data=(X_test, y_test),\n",
" margin=0.2, h=0.02, device=device)\n",
"plot2d.predict = plot2d._predict_pytorch\n",
"liveloss = PlotLosses(outputs=[plot2d])\n",
Expand Down
52 changes: 11 additions & 41 deletions livelossplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,20 @@
.. include:: ../README.md
"""

import sys
import warnings
from importlib.util import find_spec

from . import inputs, outputs
from .inputs import *
from .main_logger import MainLogger
from .plot_losses import PlotLosses
from . import inputs
from .inputs import *
from . import outputs
from .version import __version__

_input_plugin_dict = {
'keras': 'Keras',
'tf_keras': 'KerasTF',
'pytorch_ignite': 'Ignite',
'poutyne': 'Poutyne',
}


class OldDependenciesFinder:
"""
Data package module loader finder. This class sits on `sys.meta_path` and returns the
loader it knows for a given path, if it knows a compatible loader.
"""
@classmethod
def find_spec(self, fullname: str, *_, **__):
"""This functions is what gets executed by the loader.
Args:
fullname: name of the called module
"""
parts = fullname.split('.')
if len(parts) == 2 and parts[0] == 'livelossplot' and parts[1] in _input_plugin_dict:
name = parts[1]
msg = 'livelossplot.{name} will be deprecated, please use livelossplot.inputs.{name}\n'
msg += 'or use callback directly: from livelossplot import PlotLosses{new_name}'
warnings.warn(msg.format(name=name, new_name=_input_plugin_dict[name]), DeprecationWarning)
fullname = 'livelossplot.inputs.{name}'.format(name=name)
return find_spec(fullname)
return None


sys.meta_path.append(OldDependenciesFinder())

__all__ = [
'MainLogger', 'inputs', 'outputs', 'PlotLosses', 'PlotLossesKeras', 'PlotLossesKerasTF', 'PlotLossesIgnite',
'PlotLossesPoutyne'
'MainLogger',
'PlotLosses',
'PlotLossesIgnite',
'PlotLossesKeras',
'PlotLossesKerasTF',
'PlotLossesPoutyne',
'__version__',
'inputs',
'outputs',
]
3 changes: 1 addition & 2 deletions livelossplot/inputs/generic_keras.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Dict

from livelossplot.plot_losses import PlotLosses

Expand All @@ -12,7 +11,7 @@ def __init__(self, **kwargs):
"""
self.liveplot = PlotLosses(**kwargs)

def on_epoch_end(self, epoch: int, logs: Dict[str, float]):
def on_epoch_end(self, epoch: int, logs: dict[str, float]):
"""Send metrics to livelossplot
Args:
epoch: epoch number
Expand Down
6 changes: 3 additions & 3 deletions livelossplot/inputs/poutyne.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict

from poutyne.framework import Callback

from ..plot_losses import PlotLosses


Expand All @@ -11,7 +11,7 @@ def __init__(self, **kwargs):
Args:
**kwargs: keyword arguments that will be passed to PlotLosses constructor
"""
super(PlotLossesCallback, self).__init__()
super().__init__()
self.liveplot = PlotLosses(**kwargs)
self.metrics = None

Expand All @@ -21,7 +21,7 @@ def on_train_begin(self, logs):
self.metrics = list(metrics)
self.metrics += ['val_' + metric for metric in metrics]

def on_epoch_end(self, epoch: int, logs: Dict[str, float]):
def on_epoch_end(self, epoch: int, logs: dict[str, float]):
"""Send metrics to livelossplot
Args:
epoch: epoch number
Expand Down
6 changes: 3 additions & 3 deletions livelossplot/inputs/pytorch_ignite.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Optional

import ignite.engine
from ignite.handlers import global_step_from_engine

from livelossplot.plot_losses import PlotLosses


class PlotLossesCallback:
def __init__(self, train_engine: Optional[ignite.engine.Engine] = None, **kwargs):
def __init__(self, train_engine: ignite.engine.Engine | None = None, **kwargs):
"""
Args:
train_engine: engine with global step information, send metohod callback will be attached to it
Expand Down Expand Up @@ -51,5 +51,5 @@ def store(self, engine: ignite.engine.Engine):
if not self.train_engine:
self.send()

def send(self, _: Optional[ignite.engine.Engine] = None):
def send(self, _: ignite.engine.Engine | None = None):
self.liveplot.send()
1 change: 1 addition & 0 deletions livelossplot/inputs/tf_keras.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from tensorflow import keras

from .generic_keras import _PlotLossesCallback


Expand Down
Loading
Loading