fill_constant_batch_size_like(input, shape, dtype, value, input_dim_idx=0, output_dim_idx=0, force_cpu=False)
This OP creates a Tesnor accroding 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.
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 according the input.
dtype (np.dtype|core.VarDesc.VarType|str) – The data type of created Tensor which can be float32, float64, int32, int64.
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 dimension of the created Tensor is set to the batch_size value of input. The default value is 0.
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.
force_cpu (bool) – data should be on CPU if it’s true, defalut value is False.
Tensor which will be created according to dtype.
- Return type
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=, value=0, dtype='int64') #like=[[10, 10]] data=