本文簡要介紹python語言中 torch.nn.quantized.Quantize
的用法。
用法:
class torch.nn.quantized.Quantize(scale, zero_point, dtype, factory_kwargs=None)
scale-輸出量化張量的尺度
zero_point-zero_point of output Quantized Tensor
dtype-輸出量化張量的數據類型
factory_kwargs-用於配置內部緩衝區初始化的 kwargs 字典。目前支持
device
和dtype
。示例:factory_kwargs={‘device’: ‘cuda’, ‘dtype’: torch.float64}
將在當前 CUDA 設備上將內部緩衝區初始化為torch.float64
類型。請注意,dtype
僅適用於浮點緩衝區。
量化傳入的張量
- 例子::
>>> t = torch.tensor([[1., -1.], [1., -1.]]) >>> scale, zero_point, dtype = 1.0, 2, torch.qint8 >>> qm = Quantize(scale, zero_point, dtype) >>> qt = qm(t) >>> print(qt) tensor([[ 1., -1.], [ 1., -1.]], size=(2, 2), dtype=torch.qint8, scale=1.0, zero_point=2)
參數:
相關用法
- Python PyTorch QFunctional用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
- Python PyTorch Tensor.register_hook用法及代碼示例
- Python PyTorch ShardedEmbeddingBagCollection.named_parameters用法及代碼示例
- Python PyTorch sqrt用法及代碼示例
- Python PyTorch PackageImporter.id用法及代碼示例
- Python PyTorch column_stack用法及代碼示例
- Python PyTorch diag用法及代碼示例
- Python PyTorch skippable用法及代碼示例
- Python PyTorch EndOnDiskCacheHolder用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.quantized.Quantize。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。