捷徑

類型資訊

可以透過 torch.dtype 的數值屬性,透過 torch.finfotorch.iinfo 存取。

torch.finfo

class torch.finfo

torch.finfo 是一個物件,用來表示浮點數 torch.dtype 的數值特性,(例如 torch.float32torch.float64torch.float16torch.bfloat16)。 它類似於 numpy.finfo

torch.finfo 提供以下屬性:

名稱

類型

描述

bits

int

類型佔用的位元數。

eps

float

最小的可表示數字,使得 1.0 + eps != 1.0

max

float

最大的可表示數字。

min

float

最小的可表示數字 (通常是 -max)。

tiny

float

最小的正正規數字。 等同於 smallest_normal

smallest_normal

float

最小的正正規數字。 請參閱注意事項。

resolution

float

此類型的大約十進制解析度,即 10**-precision

注意

可以不帶參數呼叫 torch.finfo 的建構子,在這種情況下,該類別是為 pytorch 預設的 dtype (由 torch.get_default_dtype() 傳回) 所建立。

注意

smallest_normal 傳回最小的正規數字,但存在更小的次正規數字。 有關更多訊息,請參閱 https://en.wikipedia.org/wiki/Denormal_number

torch.iinfo

class torch.iinfo

torch.iinfo 是一個物件,用來表示整數 torch.dtype (例如 torch.uint8torch.int8torch.int16torch.int32torch.int64) 的數值特性。 它類似於 numpy.iinfo

torch.iinfo 提供以下屬性:

名稱

類型

描述

bits

int

類型佔用的位元數。

max

int

最大的可表示數字。

min

int

最小的可表示數字。

文件

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