VisualDL

class paddle.callbacks. VisualDL ( log_dir ) [source]

VisualDL callback class. After storing the loss values and evaluation metrics in a log file during the training time , the panel is launched to view the visual results.

Parameters

log_dir (str) – The directory to save visualdl log file.

Examples

>>> import paddle
>>> import paddle.vision.transforms as T
>>> from paddle.static import InputSpec

>>> inputs = [InputSpec([-1, 1, 28, 28], 'float32', 'image')]
>>> labels = [InputSpec([None, 1], 'int64', 'label')]

>>> transform = T.Compose([
...     T.Transpose(),
...     T.Normalize([127.5], [127.5])
... ])
>>> train_dataset = paddle.vision.datasets.MNIST(mode='train', transform=transform)
>>> eval_dataset = paddle.vision.datasets.MNIST(mode='test', transform=transform)

>>> net = paddle.vision.models.LeNet()
>>> model = paddle.Model(net, inputs, labels)

>>> optim = paddle.optimizer.Adam(0.001, parameters=net.parameters())
>>> model.prepare(optimizer=optim,
...             loss=paddle.nn.CrossEntropyLoss(),
...             metrics=paddle.metric.Accuracy())

>>> ## uncomment following lines to fit model with visualdl callback function
>>> # callback = paddle.callbacks.VisualDL(log_dir='visualdl_log_dir')
>>> # model.fit(train_dataset, eval_dataset, batch_size=64, callbacks=callback)
on_train_begin ( logs=None )

on_train_begin

Called at the start of training.

Parameters

logs (dict) – The logs is a dict or None.

on_epoch_begin ( epoch=None, logs=None )

on_epoch_begin

Called at the beginning of each epoch.

Parameters
  • epoch (int) – The index of epoch.

  • logs (dict) – The logs is a dict or None. The logs passed by paddle.Model is None.

on_train_batch_end ( step, logs=None )

on_train_batch_end

Called at the end of each batch in training.

Parameters
  • step (int) – The index of step (or iteration).

  • logs (dict) – The logs is a dict or None. The logs passed by paddle.Model is a dict, contains ‘loss’, metrics and ‘batch_size’ of current batch.

on_eval_begin ( logs=None )

on_eval_begin

Called at the start of evaluation.

Parameters

logs (dict) – The logs is a dict or None. The keys of logs passed by paddle.Model contains ‘steps’ and ‘metrics’, The steps is number of total steps of validation dataset. The metrics is a list of str including ‘loss’ and the names of paddle.metric.Metric.

on_train_end ( logs=None )

on_train_end

Called at the end of training.

Parameters

logs (dict) – The logs is a dict or None. The keys of logs passed by paddle.Model contains ‘loss’, metric names and batch_size.

on_eval_end ( logs=None )

on_eval_end

Called at the end of evaluation.

Parameters

logs (dict) – The logs is a dict or None. The logs passed by paddle.Model is a dict contains ‘loss’, metrics and ‘batch_size’ of last batch of validation dataset.