# chainer.training.extensions.VariableStatisticsPlot¶

class chainer.training.extensions.VariableStatisticsPlot(targets, max_sample_size=1000, report_data=True, report_grad=True, plot_mean=True, plot_std=True, percentile_sigmas=(0, 0.13, 2.28, 15.87, 50, 84.13, 97.72, 99.87, 100), trigger=(1, 'epoch'), file_name='statistics.png', figsize=None, marker=None, grid=True)[source]

Trainer extension to plot statistics for Variables.

This extension collects statistics for a single Variable, a list of Variables or similarly a single or a list of Links containing one or more Variables. In case multiple Variables are found, the means are computed. The collected statistics are plotted and saved as an image in the directory specified by the Trainer.

Statistics include mean, standard deviation and percentiles.

This extension uses reservoir sampling to preserve memory, using a fixed size running sample. This means that collected items in the sample are discarded uniformly at random when the number of items becomes larger than the maximum sample size, but each item is expected to occur in the sample with equal probability.

Parameters: targets (Variable, Link or list of either) – Parameters for which statistics are collected. max_sample_size (int) – Maximum number of running samples. report_data (bool) – If True, data (e.g. weights) statistics are plotted. If False, they are neither computed nor plotted. report_grad (bool) – If True, gradient statistics are plotted. If False, they are neither computed nor plotted. plot_mean (bool) – If True, means are plotted. If False, they are neither computed nor plotted. plot_std (bool) – If True, standard deviations are plotted. If False, they are neither computed nor plotted. percentile_sigmas (float or tuple of floats) – Percentiles to plot in the range $$[0, 100]$$. trigger – Trigger that decides when to save the plots as an image. This is distinct from the trigger of this extension itself. If it is a tuple in the form , 'epoch' or , 'iteration', it is passed to IntervalTrigger. file_name (str) – Name of the output image file under the output directory. figsize (tuple of int) – Matlotlib figsize argument that specifies the size of the output image. marker (str) – Matplotlib marker argument that specified the marker style of the plots. grid (bool) – Matplotlib grid argument that specifies whether grids are rendered in in the plots or not.

Methods

__call__(trainer)[source]

Invokes the extension.

Implementations should override this operator. This method is called at iterations which the corresponding trigger accepts.

Parameters: trainer (Trainer) – Trainer object that calls this operator.
static available()[source]
finalize()[source]

Finalizes the extension.

This method is called at the end of the training loop.

initialize(trainer)[source]

Initializes up the trainer state.

This method is called before entering the training loop. An extension that modifies the state of Trainer can override this method to initialize it.

When the trainer has been restored from a snapshot, this method has to recover an appropriate part of the state of the trainer.

For example, ExponentialShift extension changes the optimizer’s hyperparameter at each invocation. Note that the hyperparameter is not saved to the snapshot; it is the responsibility of the extension to recover the hyperparameter. The ExponentialShift extension recovers it in its initialize method if it has been loaded from a snapshot, or just setting the initial value otherwise.

Parameters: trainer (Trainer) – Trainer object that runs the training loop.
save_plot_using_module(file_path, plt)[source]
serialize(serializer)[source]

Serializes the extension state.

It is called when a trainer that owns this extension is serialized. It serializes nothing by default.

Attributes

default_name

Default name of the extension.

It is the name of the class by default. Implementation can override this property, or provide a class attribute to hide it.

name = None
priority = 100
trigger = (1, 'iteration')