mindspore.numpy.true_divide

mindspore.numpy.true_divide(x1, x2, dtype=None)[source]

Returns a true division of the inputs, element-wise.

Instead of the Python traditional “floor division”, this returns a true division.

Note

Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported.

Parameters
  • x1 (Tensor) – the dividend.

  • x2 (Tensor) – the divisor.

  • dtype (mindspore.dtype, optional) – Default: None . Overrides the dtype of the output Tensor.

Returns

Tensor or scalar, this is a scalar if both x1 and x2 are scalars.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.true_divide(x1, x2)
>>> print(output)
[[0.33333334 0.5       ]
[0.33333334 0.5       ]
[0.33333334 0.5       ]]