เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Finalize pruning by removing the mask

After pruning a model, you need to finalize it before saving or deploying. This means removing the pruning mask so the model no longer tracks which weights were zeroed. You'll use prune.remove() to complete this step.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Scalable AI Models with PyTorch Lightning

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Finalize the pruning of the weight parameter.
  • Use prune.remove() to remove the mask and store the final weights.
  • Print the model to confirm pruning removal.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

import torch.nn.utils.prune as prune
# Before pruning
print(model)
# Finalize pruning by removing the pruning mask
prune.____(model[3], "____")
# Print model structure after pruning
print(____)
แก้ไขและรันโค้ด