-
Notifications
You must be signed in to change notification settings - Fork 7.2k
ToDtype() also scales tensorsΒ #9033
Copy link
Copy link
Closed
Description
π Describe the bug
The doc of ToDtype() says that scale parameter is whether to scale the values for images or videos as shown below:
Parameters:
- ...
- scale (bool, optional) β Whether to scale the values for images or videos. See Dtype and expected value range. Default: False.
But ToDtype() also scales tensors as shown below:
from torchvision.transforms.v2 import ToDtype
import torch
td = ToDtype(dtype=torch.float32, scale=True)
td(torch.tensor([[0, 1, 2]], dtype=torch.int64))
# tensor([[0.0000e+00, 1.0842e-19, 2.1684e-19]])
td(torch.tensor([[0, 1, 2]], dtype=torch.int32))
# tensor([[0.0000e+00, 4.6566e-10, 9.3132e-10]])
td = ToDtype(dtype=torch.complex64, scale=True)
td(torch.tensor([[0., 1., 2.]], dtype=torch.float32))
td(torch.tensor([[0., 1., 2.]], dtype=torch.float64))
# tensor([[0.0000+0.j, 1.9990+0.j, 3.9980+0.j]])Versions
import torchvision
torchvision.__version__ # '0.20.1'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels