You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.ops.Fill.rst 949 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. mindspore.ops.Fill
  2. ==================
  3. .. py:class:: mindspore.ops.Fill(*args, **kwargs)
  4. 创建一个填充了Scalar值的Tensor。shape由 `shape` 参数指定,并用`value` 值填充该Tensor。
  5. **输入:**
  6. - **type** (mindspore.dtype) - 指定输出Tensor的数据类型。只支持常量值。
  7. - **shape** (tuple) - 指定输出Tensor的shape。只支持常量值。
  8. - **value** (scalar) - 用来填充输出Tensor的值。只支持常量值。
  9. **输出:**
  10. Tensor,shape为 `shape` 的值,值为 `value` 。
  11. **异常:**
  12. **TypeError** - `shape` 不是元组。
  13. **支持平台:**
  14. ``Ascend`` ``GPU`` ``CPU``
  15. **样例:**
  16. >>> fill = ops.Fill()
  17. >>> output = fill(mindspore.float32, (2, 2), 1)
  18. >>> print(output)
  19. [[1. 1.]
  20. [1. 1.]]
  21. >>> output = fill(mindspore.float32, (3, 3), 0)
  22. >>> print(output)
  23. [[0. 0. 0.]
  24. [0. 0. 0.]
  25. [0. 0. 0.]]