zeros_like

paddle.fluid.layers.zeros_like(x, out=None)[source]

This OP creates a zeros tensor which has identical shape and dtype with x.

Parameters
  • x (Variable) – The input tensor which specifies shape and dtype, the input data dtype could be bool, float32, float64, int32, int64.

  • out (Variable, optional) – If is None , the op will create the variable as output, the data type and shape of this variable will be same as input x. If is a tensor, the data type and shape need to be same as input x. The defalut value is None .

Returns

The N-D tensor, the element in tensor is related to input data type, if the input data type is bool, the output value is False, otherwise is zero. The output shape is the same as the input.

Return type

Variable

Examples

import paddle.fluid as fluid
x = fluid.data(name='x', dtype='float32', shape=[3])
data = fluid.layers.zeros_like(x) # [0.0, 0.0, 0.0]