How to use double as the default type for floating numbers in PyTorch

Viewed 5620

I want all the floating numbers in my PyTorch code double type by default, how can I do that?

2 Answers

You should use for that torch.set_default_dtype.

It is true that using torch.set_default_tensor_type will also have a similar effect, but torch.set_default_tensor_type not only sets the default data type, but also sets the default values for the device where the tensor is allocated, and the layout of the tensor.

Related