代码拉取完成,页面将自动刷新
tf.math.divide(x, y, name=None) -> Tensor
For more information, see tf.math.divide.
mindspore.ops.div(input, other, rounding_mode=None) -> Tensor
For more information, see mindspore.ops.div.
TensorFlow: The quotient is obtained by dividing two Tensors element-wise.
MindSpore: When the parameter rounding_mode of MindSpore API is None by default, MindSpore implements the same function as TensorFlow.
Categories | Subcategories | TensorFlow | MindSpore | Differences |
---|---|---|---|---|
Parameters | Parameter 1 | x | input | Same function, different parameter names |
Parameter 2 | y | other | Same function, different parameter names | |
Parameter 3 | - | rounding_mode | This parameter is not available in TensorFlow. MindSpore is an optional parameter that determines the rounding type of the result, and the default value is None | |
Parameter 4 | name | - | Not involved |
When the parameter rounding_mode of MindSpore is not specified, the two APIs achieve the same function and have the same usage.
# TensorFlow
import tensorflow as tf
import numpy
x = tf.constant([[2, 4, 6, 8], [1, 2, 3, 4]])
y = tf.constant([5, 8, 8, 16])
out = tf.math.divide(x, y).numpy()
print(out)
# [[0.4 0.5 0.75 0.5 ]
# [0.2 0.25 0.375 0.25 ]]
# MindSpore
import mindspore
from mindspore import Tensor
import mindspore.ops as ops
import numpy as np
x_ = np.array([[2, 4, 6, 8], [1, 2, 3, 4]])
y_ = np.array([5, 8, 8, 16])
x = Tensor(x_, mindspore.float64)
y = Tensor(y_, mindspore.float64)
output = ops.div(x, y)
print(output)
# [[0.4 0.5 0.75 0.5 ]
# [0.2 0.25 0.375 0.25 ]]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。