loss#

bayesflow.diagnostics.plots.loss(history: History, train_key: str = 'loss', val_key: str = 'val_loss', show_components: bool = False, component_names: Mapping[str, str] = None, smoothing_factor: float = 0.8, figsize: Sequence[float] = None, train_color: str = '#132a70', val_color: str = 'black', val_marker: str = 'o', val_marker_size: float = 5, lw_train: float = 2.0, lw_val: float = 2.0, grid_alpha: float = 0.2, legend_fontsize: int = 14, label_fontsize: int = 14, title_fontsize: int = 16) → Figure[source]#

Plot the training (and validation) loss of a series of training epochs and runs.

Parameters:
historykeras.src.callbacks.History

History object as returned by keras.Model.fit.

train_keystr, optional, default: “loss”

The training loss key to look for in the history

val_keystr, optional, default: “val_loss”

The validation loss key to look for in the history

show_componentsbool, optional, default: False

If True, every other metric in the history (e.g., regularization losses) is plotted in its own panel below the total loss, with its validation counterpart ("val_" prefix) overlaid if present.

component_namesdict, optional, default: None

Maps history keys to panel labels, e.g. {"layer_loss": "Regularization"}. Keys not in the mapping are labeled by their title-cased key.

smoothing_factorfloat, optional, default: 0.8

If greater than zero, smooth the loss curves by applying an exponential moving average.

figsizetuple or None, optional, default: None

The figure size passed to the matplotlib constructor. Inferred if None

train_colorstr, optional, default: ‘#132a70’

The color for the train loss trajectory

val_colorstr, optional, default: None

The color for the optional validation loss trajectory

val_marker: str

Marker style for the validation loss curve. Default is “o”.

val_marker_size: float

Marker size for the validation loss curve. Default is 5.

lw_trainint, optional, default: 2

The line width for the training loss curve

lw_valint, optional, default: 2

The line width for the validation loss curve

grid_alphafloat, optional, default: 0.2

The transparency of the background grid

legend_fontsizeint, optional, default: 14

The font size of the legend text

label_fontsizeint, optional, default: 14

The font size of the y-label text

title_fontsizeint, optional, default: 16

The font size of the title text

Returns:
fplt.Figure - the figure instance for optional saving