335 Star 1.5K Fork 862

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
fill.md 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
luojianing 提交于 2023-07-21 15:16 . replace target=blank

Function Differences with tf.fill

View Source On Gitee

tf.fill

tf.fill(dims, value, name=None) -> Tensor

For more information, see tf.fill.

mindspore.ops.fill

mindspore.ops.fill(type, shape, value) -> Tensor

For more information, see mindspore.ops.fill.

Differences

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

Code Example 1

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]]
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891