loss#

bayesflow.diagnostics.loss(history: History, train_key: str = 'loss', val_key: str = 'val_loss', per_training_step: bool = False, 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]#

A generic helper function to plot the losses 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

per_training_stepbool, optional, default: False

A flag for making loss trajectory detailed (to training steps) rather than per epoch.

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
Raises:
AssertionError

If the number of columns in train_losses does not match the number of columns in val_losses.