sciai.utils.to_tensor
- sciai.utils.to_tensor(tensors, dtype=ms.float32)[source]
Cast array(ies)/tensor(s) to a given MindSpore data type.
- Parameters
- Returns
Union(Tensor, tuple(Tensor)), Single one or tuple of cast tensor(s).
- Raises
TypeError – If input types are not correct.
Examples
>>> import numpy as np >>> from sciai.utils import to_tensor >>> tensors = to_tensor((np.array([1]), np.array([2]))) >>> print(tensors) (Tensor(shape=[1], dtype=Float32, value= [ 1.00000000e+00]), Tensor(shape=[1], dtype=Float32, value= [ 2.00000000e+00])) >>> print(tensors[0].dtype) Float32