Rate this Page

torch.set_default_tensor_type#

torch.set_default_tensor_type(t,/)[source]#

Warning

This function is deprecated as of PyTorch 2.1, please usetorch.set_default_dtype() andtorch.set_default_device() as alternatives.

Sets the defaulttorch.Tensor type to floating point tensor typet. This type will also be used as default floating point type fortype inference intorch.tensor().

The default floating point tensor type is initiallytorch.FloatTensor.

Parameters

t (type orstring) – the floating point tensor type or its name

Example:

>>>torch.tensor([1.2,3]).dtype# initial default for floating point is torch.float32torch.float32>>>torch.set_default_tensor_type(torch.DoubleTensor)>>>torch.tensor([1.2,3]).dtype# a new floating point tensortorch.float64