mindspore.Tensor.short
- Tensor.short()[source]
Return a copy of the tensor, cast to int16 type, equivalent to self.astype(mstype.int16). If the value in tensor is float or half, the decimal will be discarded. For details, please refer to
mindspore.Tensor.astype().- Returns
Tensor, converted to the int16 dtype.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore as ms >>> import numpy as np >>> x = ms.Tensor(np.array([1,2,3,4,5]), ms.int32) >>> output = x.short() >>> output Tensor(shape=[5], dtype=Int16, value= [1, 2, 3, 4, 5])