From 0def5938ea19a1b76b817137a6f0e3492a5ac4e7 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Thu, 25 Feb 2021 13:03:33 +0800 Subject: [PATCH] Update doc for 2.0 API and some callback (#31180) (#31189) test=document_fix --- python/paddle/fluid/layers/detection.py | 38 +++++++++++++------------ python/paddle/hapi/callbacks.py | 10 +++++-- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/python/paddle/fluid/layers/detection.py b/python/paddle/fluid/layers/detection.py index 87dd94bb17a..cf4abc207bd 100644 --- a/python/paddle/fluid/layers/detection.py +++ b/python/paddle/fluid/layers/detection.py @@ -2214,17 +2214,18 @@ def multi_box_head(inputs, Examples 1: set min_ratio and max_ratio: .. code-block:: python - import paddle.fluid as fluid + import paddle + paddle.enable_static() - images = fluid.data(name='data', shape=[None, 3, 300, 300], dtype='float32') - conv1 = fluid.data(name='conv1', shape=[None, 512, 19, 19], dtype='float32') - conv2 = fluid.data(name='conv2', shape=[None, 1024, 10, 10], dtype='float32') - conv3 = fluid.data(name='conv3', shape=[None, 512, 5, 5], dtype='float32') - conv4 = fluid.data(name='conv4', shape=[None, 256, 3, 3], dtype='float32') - conv5 = fluid.data(name='conv5', shape=[None, 256, 2, 2], dtype='float32') - conv6 = fluid.data(name='conv6', shape=[None, 128, 1, 1], dtype='float32') + images = paddle.static.data(name='data', shape=[None, 3, 300, 300], dtype='float32') + conv1 = paddle.static.data(name='conv1', shape=[None, 512, 19, 19], dtype='float32') + conv2 = paddle.static.data(name='conv2', shape=[None, 1024, 10, 10], dtype='float32') + conv3 = paddle.static.data(name='conv3', shape=[None, 512, 5, 5], dtype='float32') + conv4 = paddle.static.data(name='conv4', shape=[None, 256, 3, 3], dtype='float32') + conv5 = paddle.static.data(name='conv5', shape=[None, 256, 2, 2], dtype='float32') + conv6 = paddle.static.data(name='conv6', shape=[None, 128, 1, 1], dtype='float32') - mbox_locs, mbox_confs, box, var = fluid.layers.multi_box_head( + mbox_locs, mbox_confs, box, var = paddle.static.nn.multi_box_head( inputs=[conv1, conv2, conv3, conv4, conv5, conv6], image=images, num_classes=21, @@ -2239,17 +2240,18 @@ def multi_box_head(inputs, Examples 2: set min_sizes and max_sizes: .. code-block:: python - import paddle.fluid as fluid + import paddle + paddle.enable_static() - images = fluid.data(name='data', shape=[None, 3, 300, 300], dtype='float32') - conv1 = fluid.data(name='conv1', shape=[None, 512, 19, 19], dtype='float32') - conv2 = fluid.data(name='conv2', shape=[None, 1024, 10, 10], dtype='float32') - conv3 = fluid.data(name='conv3', shape=[None, 512, 5, 5], dtype='float32') - conv4 = fluid.data(name='conv4', shape=[None, 256, 3, 3], dtype='float32') - conv5 = fluid.data(name='conv5', shape=[None, 256, 2, 2], dtype='float32') - conv6 = fluid.data(name='conv6', shape=[None, 128, 1, 1], dtype='float32') + images = paddle.static.data(name='data', shape=[None, 3, 300, 300], dtype='float32') + conv1 = paddle.static.data(name='conv1', shape=[None, 512, 19, 19], dtype='float32') + conv2 = paddle.static.data(name='conv2', shape=[None, 1024, 10, 10], dtype='float32') + conv3 = paddle.static.data(name='conv3', shape=[None, 512, 5, 5], dtype='float32') + conv4 = paddle.static.data(name='conv4', shape=[None, 256, 3, 3], dtype='float32') + conv5 = paddle.static.data(name='conv5', shape=[None, 256, 2, 2], dtype='float32') + conv6 = paddle.static.data(name='conv6', shape=[None, 128, 1, 1], dtype='float32') - mbox_locs, mbox_confs, box, var = fluid.layers.multi_box_head( + mbox_locs, mbox_confs, box, var = paddle.static.nn.multi_box_head( inputs=[conv1, conv2, conv3, conv4, conv5, conv6], image=images, num_classes=21, diff --git a/python/paddle/hapi/callbacks.py b/python/paddle/hapi/callbacks.py index 5f2949f6513..b0a662b672d 100644 --- a/python/paddle/hapi/callbacks.py +++ b/python/paddle/hapi/callbacks.py @@ -298,13 +298,15 @@ class Callback(object): class ProgBarLogger(Callback): """ - Logger callback function. + Logger callback function to print loss and metrics to stdout. It supports + silent mode (not print), progress bar or one line per each printing, + see arguments for more detailed. Args: log_freq (int): The frequency, in number of steps, the logs such as loss, metrics are printed. Default: 1. verbose (int): The verbosity mode, should be 0, 1, or 2. - 0 = silent, 1 = progress bar, 2 = one line per epoch, 3 = 2 + + 0 = silent, 1 = progress bar, 2 = one line each printing, 3 = 2 + time counter, such as average reader cost, samples per second. Default: 2. @@ -531,7 +533,9 @@ class ProgBarLogger(Callback): class ModelCheckpoint(Callback): """ - Model checkpoint callback function. + Model checkpoint callback function to save model weights and optimizer + state during training in conjunction with model.fit(). Currently, + ModelCheckpoint only supports saving after a fixed number of epochs. Args: save_freq(int): The frequency, in number of epochs, the model checkpoint -- GitLab