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 1.0 kB

4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. mindspore.ops.Fill
  2. ==================
  3. .. py:class:: mindspore.ops.Fill()
  4. 创建一个指定shape的Tensor,并用指定值填充。
  5. **输入:**
  6. - **type** (mindspore.dtype) - 指定输出Tensor的数据类型。数据类型只支持`bool_ <https://www.mindspore.cn/docs/api/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_和`number <https://www.mindspore.cn/docs/api/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_。
  7. - **shape** (tuple[int]) - 指定输出Tensor的shape。
  8. - **value** (Union(number.Number, bool)) - 用来填充输出Tensor的值。
  9. **输出:**
  10. Tensor。
  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.]]