From 1ce6ab9cc6ebb35ea566fc1fbdc0dc8dd27ad5f9 Mon Sep 17 00:00:00 2001 From: Huihuang Zheng Date: Mon, 6 Jan 2020 16:01:02 +0800 Subject: [PATCH] Refine doc of data based on requirement. (#22098) --- python/paddle/fluid/data.py | 22 ++++++++++++++++------ python/paddle/fluid/layers/io.py | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/python/paddle/fluid/data.py b/python/paddle/fluid/data.py index 26f24f029c..6376b4f774 100644 --- a/python/paddle/fluid/data.py +++ b/python/paddle/fluid/data.py @@ -31,13 +31,23 @@ def data(name, shape, dtype='float32', lod_level=0): input into the variable. Note: - `paddle.fluid.layers.data` is deprecated. It will be removed in a future - version. Please use this `paddle.fluid.data`. + `paddle.fluid.layers.data` is deprecated. It will be removed in a + future version. Please use this `paddle.fluid.data`. - The `paddle.fluid.layers.data` set shape and dtype at compile time but - does NOT check the shape or the dtype of feeded data, this - `paddle.fluid.data` checks the shape and the dtype of data feeded by - Executor or ParallelExecutor during run time. + The `paddle.fluid.layers.data` set shape and dtype at compile time but + does NOT check the shape or the dtype of feeded data, this + `paddle.fluid.data` checks the shape and the dtype of data feeded by + Executor or ParallelExecutor during run time. + + To feed variable size inputs, users can set -1 on the variable + dimension when using :code:`paddle.fluid.data`, or feed variable size + inputs directly to :code:`paddle.fluid.layers.data` and PaddlePaddle + will fit the size accordingly. + + The default :code:`stop_gradient` attribute of the Variable created by + this API is true, which means the gradient won't be passed backward + through the data Varaible. Set :code:`var.stop_gradient = False` If + user would like to pass backward gradient. Args: name (str): The name/alias of the variable, see :ref:`api_guide_Name` diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index 21461ec9f7..ebef136d94 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -54,11 +54,21 @@ def data(name, :code:`paddle.fluid.layers.data` is deprecated as it will be removed in a later version. Please use :code:`paddle.fluid.data` . - The :code:`paddle.fluid.layers.data` set shape and dtype at compile time - but does NOT check the shape or the dtype of feeded data, this + This :code:`paddle.fluid.layers.data` set shape and dtype at compile + time but does NOT check the shape or the dtype of feeded data, the :code:`paddle.fluid.data` checks the shape and the dtype of data feeded by Executor or ParallelExecutor during run time. + To feed variable size inputs, users can feed variable size inputs + directly to this :code:`paddle.fluid.layers.data` and PaddlePaddle will + fit the size accordingly. Or set -1 on the variable dimension when using + :code:`paddle.fluid.data` . + + The default :code:`stop_gradient` attribute of the Variable created by + this API is true, which means the gradient won't be passed backward + through the data Varaible. Set :code:`var.stop_gradient = False` If + user would like to pass backward gradient. + Args: name(str): The name/alias of the variable, see :ref:`api_guide_Name` for more details.