代码拉取完成,页面将自动刷新
tf.fill(dims, value, name=None) -> Tensor
For more information, see tf.fill.
mindspore.ops.fill(type, shape, value) -> Tensor
For more information, see mindspore.ops.fill.
TensorFlow: is used to generate a tensor with scalar values.
MindSpore: MindSpore API implements the same function as TensorFlow, and only the parameter names are different.
Categories | Subcategories | TensorFlow | MindSpore | Differences |
---|---|---|---|---|
Parameters | Parameter 1 | dims | shape | Same function, different parameter names |
Parameter 2 | value | value | - | |
Parameter 3 | name | - | Not involved | |
Parameter 4 | - | type | Specify the data type of the output Tensor |
Both APIs implement the same function. MindSpore only has one more parameter specifying the type of output, and the rest of the parameters are used in the same way.
# TensorFlow
import tensorflow as tf
import numpy as np
dims = np.array([2,3])
value = 9
output = tf.fill(dims, value)
output_m = output.numpy()
print(output_m)
#[[9 9 9]
# [9 9 9]]
# MindSpore
import mindspore
import mindspore.ops as ops
type = mindspore.int32
shape = tuple((2,3))
value = 9
output = ops.fill(type, shape, value)
print(output)
#[[9 9 9]
# [9 9 9]]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。