Table of Contents
Shortcuts

# torch.set_default_tensor_type

torch.set_default_tensor_type(t)

  Sets the default `torch.Tensor` type to floating point tensor type `t`. This type will also be used as default floating point type for type inference in `torch.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

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.