oneflow.reciprocal¶
-
oneflow.
reciprocal
()¶ Computes the safe reciprocal of x. If x is zero, the reciprocal will be also set to zero.
For example:
>>> import numpy as np >>> import oneflow as flow >>> x = flow.tensor(np.array([[1, 2, 3], [4, 5, 6]]), dtype=flow.float32) >>> out = flow.reciprocal(x) >>> out.numpy() array([[1. , 0.5 , 0.33333334], [0.25 , 0.2 , 0.16666667]], dtype=float32)