On this page
torch.set_default_tensor_type
torch.set_default_tensor_type(t)[source]-
Sets the default
torch.Tensortype to floating point tensor typet. This type will also be used as default floating point type for type inference intorch.tensor().The default floating point tensor type is initially
torch.FloatTensor.- Parameters
-
t (type or string) – the floating point tensor type or its name
Example:
>>> torch.tensor([1.2, 3]).dtype # initial default for floating point is torch.float32 torch.float32 >>> torch.set_default_tensor_type(torch.DoubleTensor) >>> torch.tensor([1.2, 3]).dtype # a new floating point tensor torch.float64
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.set_default_tensor_type.html