mindspore.dataset.transforms.TypeCast ===================================== .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindspore/blob/master/docs/api/api_python/dataset_transforms/mindspore.dataset.transforms.TypeCast.rst :alt: 查看源文件 .. py:class:: mindspore.dataset.transforms.TypeCast(data_type) 将输入的Tensor转换为指定的数据类型。 .. note:: 此操作默认通过 CPU 执行,也支持异构加速到 GPU 或 Ascend 上执行。 参数: - **data_type** (Union[mindspore.dtype, numpy.dtype]) - 指定要转换的数据类型。 异常: - **TypeError** - 当 `data_type` 的类型不为 :class:`mindspore.dtype` 或 :class:`numpy.dtype` 。