PyTorch 類型信息

2020-09-15 12:03 更新

原文:PyTorch 類型信息

可以通過 torch.finfotorch.iinfo 訪問 torch.dtype 的數(shù)值屬性。

torch

class torch.finfo?

torch.finfo 是表示浮點(diǎn) torch.dtype (即torch.float32,torch.float64torch.float16)的數(shù)值屬性的對象。 這類似于 numpy.finfo 。

torch.finfo 提供以下屬性:

|

名稱

|

類型

|

描述

| | --- | --- | --- | | 位 | 整型 | 類型占用的位數(shù)。 | | eps | 浮動 | 最小可表示數(shù)字,例如1.0 + eps != 1.0。 | | 最大值 | float | 可表示的最大數(shù)字。 | | 分 | float | 最小的可表示數(shù)字(通常為-max)。 | | 小 | float | 可表示的最小正數(shù)。 |

注意

可以不帶參數(shù)地調(diào)用 torch.finfo 的構(gòu)造函數(shù),在這種情況下,將為 pytorch 默認(rèn) dtype 創(chuàng)建類(由 torch.get_default_dtype() 返回)。

torch

class torch.iinfo?

torch.iinfo 是代表整數(shù) torch.dtype (即torch.uint8,torch.int8,torch.int16,torch.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 | 可表示的最小數(shù)字。 |

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號