AI用語辞典

A comprehensive multilingual AI terminology dictionary

Definition

知識蒸留は、大規模で複雑なニューラルネットワーク(教師)を、より小さく効率的なネットワーク(学生)に圧縮するために使用される機械学習手法です。学生モデルは教師の出力分布を学習します。

Summary

知識蒸留は、小さな学生モデルが大きな教師モデルの動作を模倣するように学習させるモデル圧縮技術です。

Key Concepts

Use Cases

Code Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import torch
import torch.nn as nn

def distillation_loss(student_logits, teacher_logits, temperature=2.0):
    T = temperature
    student_probs = nn.functional.softmax(student_logits / T, dim=1)
    teacher_probs = nn.functional.softmax(teacher_logits / T, dim=1)
    return nn.functional.kl_div(
        nn.functional.log_softmax(student_logits / T, dim=1),
        teacher_probs,
        reduction='batchmean'
    ) * (T * T)