Skip to content

类型信息

译者:片刻小哥哥

项目地址:https://pytorch.apachecn.org/2.0/docs/type_info

原始地址:https://pytorch.org/docs/stable/type_info.html

torch.dtype 的数值属性可以通过 torch.finfotorch.iinfo

torch.finfo

Class torch.finfo

torch.finfo 是一个表示浮点数值属性的对象 torch.dtype ,(即 torch.float32torch.float64torch.float16torch.bfloat16 )。这类似于 numpy.finfo

torch.finfo 提供以下属性:

Name Type Description
bits int The number of bits occupied by the type.
eps float The smallest representable number such that 1.0 + eps != 1.0 .
max float The largest representable number.
min float The smallest representable number (typically -max ).
tiny float The smallest positive normal number. Equivalent to smallest_normal .
smallest_normal float The smallest positive normal number. See notes.
resolution float The approximate decimal resolution of this type, i.e., 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 提供以下属性:

Name Type Description
bits int The number of bits occupied by the type.
max int The largest representable number.
min int The smallest representable number.

我们一直在努力

apachecn/AiLearning

【布客】中文翻译组