开始使用免费开始使用

Apply dynamic quantization

You've successfully trained a neural network model for deployment, and now you want to optimize it using dynamic quantization. This step is crucial for deploying your model efficiently in environments with limited resources.

The model has been pre-loaded.

本练习是课程的一部分

Scalable AI Models with PyTorch Lightning

查看课程

练习说明

  • Import the necessary quantization module from PyTorch.
  • Apply dynamic quantization targeting linear layers, using 8-bit integer precision.

交互式实操练习

通过完成这段示例代码来试试这个练习。

import torch
# Import the necessary quantization module
from torch.quantization import ____

# Apply dynamic quantization targeting linear layers
model_quantized = torch.quantization.____(
    ____, {torch.nn.____}, dtype=torch.____
)
编辑并运行代码