"Fossies" - the Fresh Open Source Software Archive

Member "pytorch-1.8.2/docs/source/type_info.rst" (23 Jul 2021, 2301 Bytes) of package /linux/misc/pytorch-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "type_info.rst": 1.11.0_vs_1.12.0.

torch

Type Info

The numerical properties of a torch.dtype can be accessed through either the torch.finfo or the torch.iinfo.

torch.finfo

A torch.finfo is an object that represents the numerical properties of a floating point torch.dtype, (i.e. torch.float32, torch.float64, and torch.float16). This is similar to numpy.finfo.

A torch.finfo provides the following attributes:

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 representable number.
resolution float The approximate decimal resolution of this type, i.e., 10**-precision.

Note

The constructor of torch.finfo can be called without argument, in which case the class is created for the pytorch default dtype (as returned by torch.get_default_dtype).

torch.iinfo

A torch.iinfo is an object that represents the numerical properties of a integer torch.dtype (i.e. torch.uint8, torch.int8, torch.int16, torch.int32, and torch.int64). This is similar to numpy.iinfo.

A torch.iinfo provides the following attributes:

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.