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'), filename='statistics.png', figsize=None, marker=None, grid=True)[source]¶
Trainer extension to plot statistics for
Variable
s.This extension collects statistics for a single
Variable
, a list ofVariable
s or similarly a single or a list ofLink
s containing one or moreVariable
s. In case multipleVariable
s are found, the means are computed. The collected statistics are plotted and saved as an image in the directory specified by theTrainer
.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. IfFalse
, they are neither computed nor plotted.report_grad (bool) – If
True
, gradient statistics are plotted. IfFalse
, they are neither computed nor plotted.plot_mean (bool) – If
True
, means are plotted. IfFalse
, they are neither computed nor plotted.plot_std (bool) – If
True
, standard deviations are plotted. IfFalse
, 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
<int>, 'epoch'
or<int>, 'iteration'
, it is passed toIntervalTrigger
.filename (str) – Name of the output image file under the output directory. For historical reasons
file_name
is also accepted as an alias of this argument.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.
- 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. TheExponentialShift
extension recovers it in itsinitialize
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.
- on_error(trainer, exc, tb)[source]¶
Handles the error raised during training before finalization.
This method is called when an exception is thrown during the training loop, before finalize. An extension that needs different error handling from finalize, can override this method to handle errors.
- serialize(serializer)[source]¶
Serializes the extension state.
It is called when a trainer that owns this extension is serialized. It serializes nothing by default.
- __eq__(value, /)¶
Return self==value.
- __ne__(value, /)¶
Return self!=value.
- __lt__(value, /)¶
Return self<value.
- __le__(value, /)¶
Return self<=value.
- __gt__(value, /)¶
Return self>value.
- __ge__(value, /)¶
Return self>=value.
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')¶