Pytorch Torch Typename
# PyTorch torch.typename Function
* * *
[ Pytorch torch Reference Manual](https://example.com/pytorch/pytorch-torch-ref.html)
`torch.typename` is a function in PyTorch used to get the name of a data type. It accepts a tensor or data type as input and returns the string name of its type.
### Function Definition
torch.typename(input)
* * *
## Usage Examples
## Example
import torch
# Get the type name of a tensor
x = torch.tensor([1,2,3], dtype=torch.float32)
print("float32 tensor type:", torch.typename(x))
# Get the type name of a data type
dtype = torch.float64
print("float64 type:", torch.typename(dtype))
# Complex type
y = torch.tensor([1+2j], dtype=torch.complex64)
print("complex64 tensor type:", torch.typename(y))
Output:
float32 Tensor Type: torch.FloatTensor float64 Type: torch.DoubleTensor complex64 Tensor Type: torch.ComplexFloatTensor
* * *
[ Pytorch torch Reference Manual](https://example.com/pytorch/pytorch-torch-ref.html)
YouTip