equal

paddle.fluid.layers.equal(x, y, cond=None)[source]

This layer returns the truth value of \(x == y\) elementwise.

Parameters
  • x (Variable) – Tensor, data type is float32, float64, int32, int64.

  • y (Variable) – Tensor, data type is float32, float64, int32, int64.

  • cond (Variable, optional) – Optional output which can be any created Variable that meets the requirements to store the result of equal. if cond is None, a new Varibale will be created to store the result.

Returns

output Tensor, it’s shape is the same as the input’s Tensor, and the data type is bool.

Return type

Variable

Examples

import paddle.fluid as fluid
import numpy as np
out_cond =fluid.data(name="input1", shape=[2], dtype='bool')
label = fluid.layers.assign(np.array([3, 3], dtype="int32"))
limit = fluid.layers.assign(np.array([3, 2], dtype="int32"))
label_cond = fluid.layers.assign(np.array([1, 2], dtype="int32"))
out1 = fluid.layers.equal(x=label,y=limit) #out1=[True, False]
out2 = fluid.layers.equal(x=label_cond,y=limit, cond=out_cond) #out2=[False, True] out_cond=[False, True]