本文簡要介紹python語言中 torch.quantize_per_channel
的用法。
用法:
torch.quantize_per_channel(input, scales, zero_points, axis, dtype) → Tensor
input(Tensor) -浮點張量量化
scales(Tensor) -浮點數 1D 張量使用,大小應匹配
input.size(axis)
zero_points(int) -要使用的偏移量的整數 1D 張量,大小應匹配
input.size(axis)
axis(int) -應用每通道量化的維度
dtype(
torch.dtype
) -返回張量的所需數據類型。必須是量化數據類型之一:torch.quint8
、torch.qint8
、torch.qint32
一個新量化的張量
將浮點張量轉換為具有給定比例和零點的每通道量化張量。
例子:
>>> x = torch.tensor([[-1.0, 0.0], [1.0, 2.0]]) >>> torch.quantize_per_channel(x, torch.tensor([0.1, 0.01]), torch.tensor([10, 0]), 0, torch.quint8) tensor([[-1., 0.], [ 1., 2.]], size=(2, 2), dtype=torch.quint8, quantization_scheme=torch.per_channel_affine, scale=tensor([0.1000, 0.0100], dtype=torch.float64), zero_point=tensor([10, 0]), axis=0) >>> torch.quantize_per_channel(x, torch.tensor([0.1, 0.01]), torch.tensor([10, 0]), 0, torch.quint8).int_repr() tensor([[ 0, 10], [100, 200]], dtype=torch.uint8)
參數:
返回:
返回類型:
相關用法
- Python PyTorch quantize_per_tensor用法及代碼示例
- Python PyTorch quantized_max_pool2d用法及代碼示例
- Python PyTorch quantized_max_pool1d用法及代碼示例
- Python PyTorch quantized_batch_norm用法及代碼示例
- Python PyTorch quantile用法及代碼示例
- Python PyTorch qr用法及代碼示例
- 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用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.quantize_per_channel。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。