# abcdpan/mt2kd architecture

> Architecture diagram of the GitHub repository abcdpan/mt2kd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abcdpan/mt2kd
- Repository: https://github.com/abcdpan/mt2kd

## Overview

MT²KD trains teacher-side classifiers at selected temperatures, then distills a student using those classifiers and a frozen teacher. The repository also includes a general teacher/student distillation workflow with multiple losses, including CRD, plus CIFAR-100 and ImageNet data support. The diagram captures documented workflow stages and source-visible calls; unsampled training logic and optional method wiring are not inferred.

Main entry points: [`train_student.py`](https://github.com/abcdpan/mt2kd/blob/main/train_student.py) (General distillation), [`MT2KD/train_student_muilti_to_muilti.py`](https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_student_muilti_to_muilti.py) (Multi-temperature student), [`MT2KD/train_teacherCls.py`](https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_teacherCls.py) (Teacher classifiers), [`models`](https://github.com/abcdpan/mt2kd/tree/main/models) (Teacher networks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training workflows"]
  node_teacher_cls["Teacher classifiers"]
  node_multi_student["Multi-temperature student"]
  node_general_student["General distillation<br/>[train_student.py]"]
  node_teacher_train["Teacher training<br/>[train_teacher.py]"]
end

subgraph group_models["Networks and losses"]
  node_teacher_model["Teacher networks"]
  node_student_model["Student networks"]
  node_multi_classifier["Multi-head classifiers<br/>[resnet_multiCls.py]"]
  node_classifier["Classifier module<br/>[classifier.py]"]
  node_distillers["Distillation losses"]
  node_crd_loss["CRD objective<br/>[criterion.py]"]
  node_crd_memory[("Contrast memory<br/>[memory.py]")]
end

subgraph group_data["Datasets"]
  node_cifar_data["CIFAR-100 loaders<br/>[cifar100.py]"]
  node_imagenet_data["ImageNet loaders<br/>[imagenet.py]"]
end

subgraph group_support["Training support"]
  node_distill_loop["Distillation loop<br/>[loops.py]"]
  node_multi_loop["MT²KD loop<br/>[loops_ours.py]"]
  node_model_utils["Feature adapters<br/>[util.py]"]
  node_train_utils["Metrics and schedules<br/>[util.py]"]
end

node_user(("Researcher"))

node_user -->|"trains classifiers"| node_teacher_cls
node_user -->|"trains student"| node_multi_student
node_teacher_cls -->|"loads data"| node_cifar_data
node_teacher_cls -->|"loads data"| node_imagenet_data
node_teacher_cls -.->|"loads teacher"| node_teacher_model
node_teacher_cls -.->|"trains classifier"| node_multi_classifier
node_multi_student -.->|"loads teacher"| node_teacher_model
node_multi_student -.->|"builds student"| node_student_model
node_multi_student -->|"loads classifiers"| node_multi_classifier
node_multi_student -.->|"loads data"| node_cifar_data
node_multi_student -.->|"loads data"| node_imagenet_data
node_multi_student -->|"runs training loop"| node_multi_loop
node_teacher_train -->|"builds teacher"| node_teacher_model
node_teacher_train -->|"loads data"| node_cifar_data
node_teacher_train -->|"uses training loop"| node_distill_loop
node_general_student -->|"builds student"| node_student_model
node_general_student -.->|"loads teacher"| node_teacher_model
node_general_student -.->|"loads data"| node_cifar_data
node_general_student -.->|"loads data"| node_imagenet_data
node_general_student -->|"selects loss"| node_distillers
node_general_student -->|"builds CRD loss"| node_crd_loss
node_general_student -->|"runs training loop"| node_distill_loop
node_crd_loss -->|"computes contrast"| node_crd_memory
node_multi_student -.->|"uses adapters"| node_model_utils
node_multi_loop -->|"uses metrics"| node_train_utils
node_distill_loop -->|"uses metrics"| node_train_utils
node_general_student -->|"builds adapters"| node_model_utils

click node_teacher_cls "https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_teacherCls.py"
click node_multi_student "https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_student_muilti_to_muilti.py"
click node_general_student "https://github.com/abcdpan/mt2kd/blob/main/train_student.py"
click node_teacher_train "https://github.com/abcdpan/mt2kd/blob/main/train_teacher.py"
click node_teacher_model "https://github.com/abcdpan/mt2kd/tree/main/models"
click node_student_model "https://github.com/abcdpan/mt2kd/tree/main/models"
click node_multi_classifier "https://github.com/abcdpan/mt2kd/blob/main/models/resnet_multiCls.py"
click node_classifier "https://github.com/abcdpan/mt2kd/blob/main/models/classifier.py"
click node_distillers "https://github.com/abcdpan/mt2kd/tree/main/distiller_zoo"
click node_crd_loss "https://github.com/abcdpan/mt2kd/blob/main/crd/criterion.py"
click node_crd_memory "https://github.com/abcdpan/mt2kd/blob/main/crd/memory.py"
click node_cifar_data "https://github.com/abcdpan/mt2kd/blob/main/dataset/cifar100.py"
click node_imagenet_data "https://github.com/abcdpan/mt2kd/blob/main/dataset/imagenet.py"
click node_distill_loop "https://github.com/abcdpan/mt2kd/blob/main/helper/loops.py"
click node_multi_loop "https://github.com/abcdpan/mt2kd/blob/main/MT2KD/loops_ours.py"
click node_model_utils "https://github.com/abcdpan/mt2kd/blob/main/models/util.py"
click node_train_utils "https://github.com/abcdpan/mt2kd/blob/main/helper/util.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_teacher_cls,node_multi_student,node_general_student,node_teacher_train toneBlue
class node_teacher_model,node_student_model,node_multi_classifier,node_classifier,node_distillers,node_crd_loss,node_crd_memory toneAmber
class node_cifar_data,node_imagenet_data toneMint
class node_distill_loop,node_multi_loop,node_model_utils,node_train_utils toneRose
class node_user toneIndigo
```

## Components

### Training workflows

- [Teacher classifiers](https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_teacherCls.py): `MT2KD/train_teacherCls.py`
- [Multi-temperature student](https://github.com/abcdpan/mt2kd/blob/main/MT2KD/train_student_muilti_to_muilti.py): `MT2KD/train_student_muilti_to_muilti.py`
- [General distillation](https://github.com/abcdpan/mt2kd/blob/main/train_student.py): `train_student.py`
- [Teacher training](https://github.com/abcdpan/mt2kd/blob/main/train_teacher.py): `train_teacher.py`

### Networks and losses

- [Teacher networks](https://github.com/abcdpan/mt2kd/tree/main/models): `models`
- [Student networks](https://github.com/abcdpan/mt2kd/tree/main/models): `models`
- [Multi-head classifiers](https://github.com/abcdpan/mt2kd/blob/main/models/resnet_multiCls.py): `models/resnet_multiCls.py`
- [Classifier module](https://github.com/abcdpan/mt2kd/blob/main/models/classifier.py): `models/classifier.py`
- [Distillation losses](https://github.com/abcdpan/mt2kd/tree/main/distiller_zoo): `distiller_zoo`
- [CRD objective](https://github.com/abcdpan/mt2kd/blob/main/crd/criterion.py): `crd/criterion.py`
- [Contrast memory](https://github.com/abcdpan/mt2kd/blob/main/crd/memory.py): `crd/memory.py`

### Datasets

- [CIFAR-100 loaders](https://github.com/abcdpan/mt2kd/blob/main/dataset/cifar100.py): `dataset/cifar100.py`
- [ImageNet loaders](https://github.com/abcdpan/mt2kd/blob/main/dataset/imagenet.py): `dataset/imagenet.py`

### Training support

- [Distillation loop](https://github.com/abcdpan/mt2kd/blob/main/helper/loops.py): `helper/loops.py`
- [MT²KD loop](https://github.com/abcdpan/mt2kd/blob/main/MT2KD/loops_ours.py): `MT2KD/loops_ours.py`
- [Feature adapters](https://github.com/abcdpan/mt2kd/blob/main/models/util.py): `models/util.py`
- [Metrics and schedules](https://github.com/abcdpan/mt2kd/blob/main/helper/util.py): `helper/util.py`

### Other components

- **Researcher**

## Connections

- Researcher → Teacher classifiers: trains classifiers (evidence: `README.md`)
- Researcher → Multi-temperature student: trains student (evidence: `README.md`)
- Teacher classifiers → CIFAR-100 loaders: loads data (evidence: `MT2KD/train_teacherCls.py`)
- Teacher classifiers → ImageNet loaders: loads data (evidence: `MT2KD/train_teacherCls.py`)
- Teacher classifiers → Teacher networks: loads teacher (evidence: `MT2KD/train_teacherCls.py`)
- Teacher classifiers → Multi-head classifiers: trains classifier
- Multi-temperature student → Teacher networks: loads teacher (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- Multi-temperature student → Student networks: builds student (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- Multi-temperature student → Multi-head classifiers: loads classifiers (evidence: `README.md`)
- Multi-temperature student → CIFAR-100 loaders: loads data (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- Multi-temperature student → ImageNet loaders: loads data (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- Multi-temperature student → MT²KD loop: runs training loop (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- Teacher training → Teacher networks: builds teacher (evidence: `train_teacher.py`)
- Teacher training → CIFAR-100 loaders: loads data (evidence: `train_teacher.py`)
- Teacher training → Distillation loop: uses training loop (evidence: `train_teacher.py`)
- General distillation → Student networks: builds student (evidence: `train_student.py`)
- General distillation → Teacher networks: loads teacher (evidence: `train_student.py`)
- General distillation → CIFAR-100 loaders: loads data (evidence: `train_student.py`)
- General distillation → ImageNet loaders: loads data
- General distillation → Distillation losses: selects loss (evidence: `train_student.py`)
- General distillation → CRD objective: builds CRD loss (evidence: `train_student.py`)
- General distillation → Distillation loop: runs training loop (evidence: `train_student.py`)
- CRD objective → Contrast memory: computes contrast (evidence: `crd/criterion.py`)
- Multi-temperature student → Feature adapters: uses adapters (evidence: `MT2KD/train_student_muilti_to_muilti.py`)
- MT²KD loop → Metrics and schedules: uses metrics (evidence: `MT2KD/loops_ours.py`)
- Distillation loop → Metrics and schedules: uses metrics (evidence: `helper/loops.py`)
- General distillation → Feature adapters: builds adapters (evidence: `train_student.py`)
