data( name, shape, append_batch_size=True, dtype='float32', lod_level=0, type=VarType.LOD_TENSOR, stop_gradient=True )
This operator creates the global variable. The global variables can be accessed by all the following operators in the graph.
paddle.fluid.layers.datais deprecated as it will be removed in a later version. Please use
paddle.fluid.layers.dataset shape and dtype at compile time but does NOT check the shape or the dtype of fed data, the
paddle.fluid.datachecks the shape and the dtype of data fed by Executor or ParallelExecutor during run time.
To feed variable size inputs, users can feed variable size inputs directly to this
paddle.fluid.layers.dataand PaddlePaddle will fit the size accordingly. Or set -1 on the variable dimension when using
stop_gradientattribute of the Variable created by this API is true, which means the gradient won’t be passed backward through the data Varaible. Set
var.stop_gradient = FalseIf user would like to pass backward gradient.
name (str) – The name/alias of the variable, see Name for more details.
shape (list|tuple) – Tuple declaring the shape. If
append_batch_sizeis True and there is no -1 inside
shape, it should be considered as the shape of the each sample. Otherwise, it should be considered as the shape of the batched data.
append_batch_size (bool) –
If true, it prepends -1 to the shape.
For example if shape=, the resulting shape is [-1, 1]. This will be useful to set different batch size at run time.
If shape contains -1, such as shape=[1, -1].
append_batch_size will be enforced to be be False (ineffective) because PaddlePaddle cannot set more than 1 unknown number on the shape.
dtype (np.dtype|VarType|str) – The type of the data. Supported dtype: bool, float16, float32, float64, int8, int16, int32, int64, uint8.
type (VarType) – The output type. Supported dtype: VarType.LOD_TENSOR, VarType.SELECTED_ROWS, VarType.NCCL_ID. Default: VarType.LOD_TENSOR.
lod_level (int) – The LoD Level. 0 means the input data is not a sequence. Default: 0.
stop_gradient (bool) – A boolean that mentions whether gradient should flow. Default: True.
The global variable that gives access to the data.
- Return Type:
import paddle.fluid as fluid data = fluid.layers.data(name='x', shape=, dtype='float32')