megengine.functional.equal

equal(x, y)[源代码]

逐元素判断是否相等。

实际案例

import numpy as np
from megengine import tensor
import megengine.functional as F

x = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3))
y = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3))
out = F.equal(x, y)
print(out.numpy())

输出:

[[1. 1. 1.]
 [1. 1. 1.]]