sciai.utils.to_tensor ======================= .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/r2.2/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindscience/blob/r0.5/docs/api_python/sciai/utils/sciai.utils.to_tensor.rst :alt: 查看源文件 .. py:function:: sciai.utils.to_tensor(tensors, dtype=ms.float32) 将数组/张量转换为给定的MindSpore数据类型。 参数: - **tensors** (Union[Tensor, ndarray, Number, np.floating, tuple[Tensor, ndarray]]) - 要转换的若干Tensor。 - **dtype** (type) - 目标Mindspore Tensor数据类型。 默认值:ms.float32。 返回: Union(Tensor, tuple(Tensor)) - 单个或元组张量。 异常: - **TypeError** 如果输入类型不正确。