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

17 lines
996 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.asfarray
=================================
.. py:function:: mindspore.numpy.asfarray(a, dtype=mstype.float32)
类似于 ``asarray`` 将输入转换为float tensor。如果 ``dtype`` 定义的是一个non-float格式则该函数将返回float32格式的Tensor。
参数:
- **a** (Union[int, float, bool, list, tuple, Tensor]) - 可以转换为Tensor的任何形式的输入数据。 包含 ``int, float, bool, Tensor, list, tuple``
- **dtype** (Union[mindspore.dtype, str], 可选) - 指定Tensor的数据类型可以是 ``np.int32````int32`` 。如果 ``dtype````None`` ,则将从 ``a`` 推断出新Tensor的数据类型。默认值 ``mstype.float32``
返回:
Tensor具有指定的float数据类型。
异常:
- **TypeError** - 如果没有按照上述内容给定的数据类型输入参数。
- **ValueError** - 如果输入 ``a`` 在不同的维度上具有不同的大小。