mindspore/docs/api/api_python/numpy/mindspore.numpy.ones.rst

18 lines
679 B
ReStructuredText
Raw Permalink 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.numpy.ones
=================================
.. py:function:: mindspore.numpy.ones(shape, dtype=mstype.float32)
返回一个给定shape和类型的新Tensor其中所有元素用1来填充。
参数:
- **shape** (Union[int, tuple, list]) - 指定Tensor的shape。
- **dtype** (Union[mindspore.dtype, str], 可选) - 指定的Tensor ``dtype`` 。默认值: ``mstype.float32``
返回:
Tensor给定 ``shape````dtype`` 其中所有元素都为1。
异常:
- **TypeError** - 如果输入参数非上述给定的类型。
- **ValueError** - 如果 ``shape`` 的元素项值 :math:`<0`