ConvertImageDtype¶
- class torchvision.transforms.v2.ConvertImageDtype(dtype: dtype = torch.float32)[source]¶
[已棄用] 請改用
v2.ToDtype(dtype, scale=True)。將輸入影像轉換為指定的
dtype並相應地縮放值。警告
建議改用
ToDtype(dtype, scale=True)。請參閱ToDtype。此函式不支援 PIL Image。
- 引數:
dtype (torch.dpython:type) – 期望的輸出資料型別
注意
當從較小整數
dtype轉換為較大整數dtype時,最大值不會精確對映。如果來回轉換,這種不匹配沒有影響。- 引發:
RuntimeError – 嘗試將
torch.float32轉換為torch.int32或torch.int64,以及嘗試將torch.float64轉換為torch.int64時會引發此錯誤。這些轉換可能導致溢位錯誤,因為浮點dtype無法在其整個範圍內儲存整數dtype的連續整數。