Tutorial -- Learning not only technology, but also dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
PyTorch Tutorial
- PyTorch Tutorial
- PyTorch Introduction
- PyTorch Installation
- PyTorch Basics
- PyTorch Tensors
- PyTorch Neural Network Basics
- PyTorch First Neural Network
- PyTorch Data Processing and Loading
- PyTorch Linear Regression
- PyTorch Convolutional Neural Network
- PyTorch Recurrent Neural Network
- PyTorch Datasets
- PyTorch Data Transforms
- Pytorch torch Reference
- PyTorch torch.nn Reference
- Transformer Model
- PyTorch Transformer
- PyTorch torch.optim
- PyTorch torchvision
- PyTorch Model Deployment
- PyTorch Model Save and Load
- PyTorch Image Classification
- PyTorch Text Sentiment Analysis
- PyTorch Autograd
- PyTorch GPU / CUDA Acceleration
- PyTorch Loss Functions
- PyTorch Learning Rate Scheduler
- PyTorch Transfer Learning
- PyTorch Batch Normalization
- PyTorch LSTM / GRU
- PyTorch Word Embedding
- PyTorch GAN
- PyTorch Autoencoder
- PyTorch Model Evaluation and Debugging
- PyTorch torchtext
- PyTorch Mixed Precision Training
- PyTorch TorchScript/ONNX Export
- PyTorch Distributed Training
- PyTorch Attention Mechanism
PyTorch torch.quantize_per_channel Function
torch.quantize_per_channel is a PyTorch function used to create a quantized tensor with per-channel quantization.
Function Definition
torch.quantize_per_channel(input, scales, zero_points, axis, dtype)
Usage Example
import torch
# Create input tensor (2D)
input = torch.tensor([[-1.0,0.0],[1.0,2.0]])
# Per-channel quantization
# scales: scaling factors for each channel
# zero_points: zero points for each channel
# axis: dimension along which to quantize
scales = torch.tensor([0.1,0.2])
zero_points = torch.tensor([10,10])
axis = 0
x = torch.quantize_per_channel(input, scales, zero_points, axis, dtype=torch.quint8)
print("Quantized tensor:")
print(x)
print("Dequantized original values:")
print(x.dequantize())
```
YouTip
Pytorch torch Reference