fill_constant_batch_size_like

paddle.fluid.layers.tensor. fill_constant_batch_size_like ( input, shape, dtype, value, input_dim_idx=0, output_dim_idx=0, force_cpu=False ) [source]

Warning: API “paddle.fluid.layers.tensor.fill_constant_batch_size_like” is deprecated since 1.8.0, and will be removed in future versions. Please use “paddle.fluid.layers.fill_constant” instead.

This OP creates a Tesnor according the shape and dtype, and initializes the Tensor with the constants provided in value. When the input is LoDTensor and the input_dim_idx is 0, the output_dim_idx dimension is set to the value of the batch_size input by the input, the Stop_gradient attribute of the created Tensor is False by default.

Args:

input(Variable): Tensor which data type is float32, float64, int32 and int64. shape(list): The shape of Tensor to be created, Tensor’s shape may be changed

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 12)

Unexpected indentation.

according the input.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 13)

Block quote ends without a blank line; unexpected unindent.

dtype(np.dtype|core.VarDesc.VarType|str): The data type of created Tensor which

can be float32, float64, int32, int64.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 15)

Definition list ends without a blank line; unexpected unindent.

value(float|int): The constant value used to initialize the Tensor to be created. input_dim_idx(int): When the value is 0 and the input is LoDTensor, the output_dim_idx

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 17)

Unexpected indentation.

dimension of the created Tensor is set to the batch_size value of input. The default value is 0.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 19)

Block quote ends without a blank line; unexpected unindent.

output_dim_idx(int): Used to specify which dimension of Tensor is created to be set

the value of batch_size of input Tensor. The default value is 0.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.tensor.fill_constant_batch_size_like, line 21)

Definition list ends without a blank line; unexpected unindent.

force_cpu(bool): data should be on CPU if it’s true, default value is False.

Returns:

Variable: Tensor which will be created according to dtype.

Examples:

import paddle.fluid as fluid
like = fluid.layers.fill_constant(shape=[1,2], value=10, dtype='int64') #like=[[10, 10]]
data = fluid.layers.fill_constant_batch_size_like(
       input=like, shape=[1], value=0, dtype='int64') #like=[[10, 10]] data=[0]