How to know the type of a tensor?

I tried print(type(a_tensor)) but its only telling me that its a tensor. How do i know if it is float type or double type or whatever it may be ? Please help

Hi,
You can find data types of tensors using:

>>> import torch
>>> a = torch.tensor([1, 2, 3])
>>> a.dtype
torch.int64

Hope it helps. Thanks!

3 Likes