mindspore/docs/api/api_python/ops/mindspore.ops.Fill.rst

38 lines
949 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.Fill
==================
.. py:class:: mindspore.ops.Fill(*args, **kwargs)
创建一个填充了Scalar值的Tensor。shape由 `shape` 参数指定,并用`value` 值填充该Tensor。
**输入:**
- **type** (mindspore.dtype) - 指定输出Tensor的数据类型。只支持常量值。
- **shape** (tuple) - 指定输出Tensor的shape。只支持常量值。
- **value** (scalar) - 用来填充输出Tensor的值。只支持常量值。
**输出:**
Tensorshape为 `shape` 的值,值为 `value`
**异常:**
**TypeError** - `shape` 不是元组。
**支持平台:**
``Ascend`` ``GPU`` ``CPU``
**样例:**
>>> fill = ops.Fill()
>>> output = fill(mindspore.float32, (2, 2), 1)
>>> print(output)
[[1. 1.]
[1. 1.]]
>>> output = fill(mindspore.float32, (3, 3), 0)
>>> print(output)
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]