argument

Set dtype with dtype argument functions and get it in PyTorch

Set dtype with dtype argument functions and get it in PyTorch

You can set dtype with the functions which have dtype arguments and get it with dtype and type() as shown below: *Memos: tensor(). *My post explains tensor(): import torch my_tensor = torch.tensor([0, 1, 2]) my_tensor = torch.tensor([0, 1, 2], dtype=torch.int64) my_tensor = torch.tensor([0, 1, 2], dtype=int) my_tensor, my_tensor.dtype, my_tensor.type() # (tensor([0, 1, 2]), torch.int64, 'torch.LongTensor') my_tensor = torch.tensor([0., 1., 2.], dtype=torch.float64) my_tensor = torch.tensor([0., 1., 2.], dtype=float) my_tensor, my_tensor.dtype, my_tensor.type() # (tensor([0., 1., 2.], dtype=torch.float64), # torch.float64, # 'torch.DoubleTensor') my_tensor = torch.tensor([0.+7.j, 1.+4.j, 2.+5.j], dtype=torch.complex32) my_tensor, my_tensor.dtype, my_tensor.type() # (tensor([0.+7.j, 1.+4.j, 2.+5.j], dtype=torch.complex32), # torch.complex32, # 'torch.ComplexHalfTensor') my_tensor = torch.tensor([True,…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.