YouTip LogoYouTip

Pytorch Torch Typename

# PyTorch torch.typename Function * * * [![Image 3: Pytorch torch Reference Manual](https://example.com/images/up.gif) 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 * * * [![Image 4: Pytorch torch Reference Manual](https://example.com/images/up.gif) Pytorch torch Reference Manual](https://example.com/pytorch/pytorch-torch-ref.html)
← Pytorch Torch UnflattenPytorch Torch True_Divide β†’