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.OnesLike.rst 658 B

4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132
  1. mindspore.ops.OnesLike
  2. ======================
  3. .. py:class:: mindspore.ops.OnesLike()
  4. 返回值为1的Tensor,shape和数据类型与输入相同。
  5. **输入:**
  6. - **input_x** (Tensor) - 任意维度的Tensor。
  7. **输出:**
  8. Tensor,具有与 `input_x` 相同的shape和类型,并填充了1。
  9. **异常:**
  10. - **TypeError** - `input_x` 不是Tensor。
  11. **支持平台:**
  12. ``Ascend`` ``GPU`` ``CPU``
  13. **样例:**
  14. >>> oneslike = ops.OnesLike()
  15. >>> input_x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32))
  16. >>> output = oneslike(input_x)
  17. >>> print(output)
  18. [[1 1]
  19. [1 1]]