Home

Awesome

LGCNS AI Research pytorch

Self-Knowledge Distillation with Progressive Refinement of Targets (PS-KD)

Accepted at ICCV 2021, oral presentation

Abstract

The generalization capability of deep neural networks has been substantially improved by applying a wide spectrum of regularization methods, e.g., restricting function space, injecting randomness during training, augmenting data, etc. In this work, we propose a simple yet effective regularization method named progressive self-knowledge distillation (PS-KD), which progressively distills a model's own knowledge to soften hard targets (i.e., one-hot vectors) during training. Hence, it can be interpreted within a framework of knowledge distillation as a student becomes a teacher itself. Specifically, targets are adjusted adaptively by combining the ground-truth and past predictions from the model itself. Please refer to the paper for more details.

<p align="center"> <img src="images/overview.png" height=200> </p>

Requirements

We have tested the code on the following environments:

Datasets

Currently, only CIFAR-100, ImageNet dataset is supported.

#) To verify the effectivness of PS-KD on Detection task and Machine translation task, we used

How to Run

Single-GPU Training

To train a model on single-GPU, run the command as follows:

$ CUDA_VISIBLE_DEVICES='<GPU ID>' python3 main.py --lr 0.1 \
                  --lr_decay_schedule 150 225 \
                  --PSKD \
                  --experiments_dir '<set your own path>' \
                  --batch_size 128 \
                  --classifier_type 'ResNet18' \
                  --data_path '<root your own data path>' \
                  --data_type '<cifar100 or imagenet>' \
                  --alpha_T 0.8 \

Single-node & Multi-GPU Training

To train a model with 1 nodes & multi-GPU, run the command as follows:

$ CUDA_VISIBLE_DEVICES='<GPU IDs>' python3 main.py --lr 0.1 \
                  --lr_decay_schedule 150 225 \
                  --PSKD \
                  --experiments_dir '<set your own path>' \
                  --batch_size 128 \
                  --classifier_type 'ResNet18' \
                  --data_path '<root your own data path>' \
                  --data_type '<cifar100 or imagenet>' \
                  --alpha_T 0.8 \
                  --rank 0 \
                  --world_size 1 \
                  --multiprocessing_distributed

Multi-node Training

To train a model with 2 nodes, for instance, run the commands below in sequence:

# on the node #0
$ CUDA_VISIBLE_DEVICES='<GPU IDs>' python3 main.py --lr 0.1 \
                  --lr_decay_schedule 150 225 \
                  --PSKD \
                  --experiments_dir '<set your own path>' \a
                  --batch_size 64 \
                  --classifier_type 'ResNet18' \
                  --data_path '<root your own data path>' \
                  --data_type '<cifar100 or imagenet>' \
                  --alpha_T 0.8 \
                  --rank 0 \
                  --world_size 2 \
                  --dist_url tcp://{master_ip}:{master_port} \
                  --multiprocessing_distributed
# on the node #1
$ CUDA_VISIBLE_DEVICES='<GPU IDs>' python3 main.py --lr 0.1 \
                  --lr_decay_schedule 150 225 \
                  --PSKD \
                  --experiments_dir '<set your own path>' \
                  --batch_size 64 \
                  --classifier_type 'ResNet18' \
                  --data_path '<root your own data path>' \
                  --data_type '<cifar100 or imagenet>' \
                  --alpha_T 0.8 \
                  --rank 1 \
                  --world_size 2 \
                  --dist_url tcp://{master_ip}:{master_port} \
                  --multiprocessing_distributed

Saving & Loading Checkpoints

Saved Filenames

Loading Checkpoints (resume)

Experimental Results

Performance measures

Results on CIFAR-100

Model + MethodDatasetTop-1 ErrorTop-5 ErrorNLLECEAURC
PreAct ResNet-18 (baseline)CIFAR-10024.186.901.1011.8467.65
PreAct ResNet-18 + Label SmoothingCIFAR-10020.946.020.9810.7957.74
PreAct ResNet-18 + CS-KD [CVPR'20]CIFAR-10021.305.700.886.2456.56
PreAct ResNet-18 + TF-KD [CVPR'20]CIFAR-10022.886.011.0511.9661.77
PreAct ResNet-18 + PS-KDCIFAR-10020.825.100.761.7752.10
PreAct ResNet-101 (baseline)CIFAR-10020.755.280.8910.0255.45
PreAct ResNet-101 + Label SmoothingCIFAR-10019.845.070.933.4395.76
PreAct ResNet-101 + CS-KD [CVPR'20]CIFAR-10020.765.621.0212.1864.44
PreAct ResNet-101 + TF-KD [CVPR'20]CIFAR-10020.135.100.846.1458.8
PreAct ResNet-101 + PS-KDCIFAR-10019.434.300.746.9249.01
DenseNet-121 (baseline)CIFAR-10020.054.990.827.3452.21
DenseNet-121 + Label SmoothingCIFAR-10019.805.460.923.7691.06
DenseNet-121 + CS-KD [CVPR'20]CIFAR-10020.476.211.0713.8073.37
DenseNet-121 + TF-KD [CVPR'20]CIFAR-10019.885.100.857.3369.23
DenseNet-121 + PS-KDCIFAR-10018.733.900.693.7145.55
ResNeXt-29 (baseline)CIFAR-10018.654.470.744.1744.27
ResNeXt-29 + Label SmoothingCIFAR-10017.604.231.0522.1441.92
ResNeXt-29 + CS-KD [CVPR'20]CIFAR-10018.264.370.805.9542.11
ResNeXt-29 + TF-KD [CVPR'20]CIFAR-10017.333.870.746.7340.34
ResNeXt-29 + PS-KDCIFAR-10017.283.600.729.1840.19
PyramidNet-200 (baseline)CIFAR-10016.803.690.738.0436.95
PyramidNet-200 + Label SmoothingCIFAR-10017.824.720.893.46105.02
PyramidNet-200 + CS-KD [CVPR'20]CIFAR-10018.315.701.1714.7070.05
PyramidNet-200 + TF-KD [CVPR'20]CIFAR-10016.483.370.7910.4837.04
PyramidNet-200 + PS-KDCIFAR-10015.493.080.561.8332.14

Results on ImageNet

Model +MethodDatasetTop-1 ErrorTop-5 ErrorNLLECEAURC
DenseNet-264*ImageNet22.156.12------
ResNet-152ImageNet22.196.190.883.8461.79
ResNet-152 + Label SmoothingImageNet21.735.850.923.9168.24
ResNet-152 + CS-KD [CVPR'20]ImageNet21.615.920.905.7962.12
ResNet-152 + TF-KD [CVPR'20]ImageNet22.766.430.914.7065.28
ResNet-152 + PS-KDImageNet21.415.860.842.5161.01

* denotes results reported in the original papers

Citation

If you find this repository useful, please consider giving a star :star: and citation PS-KD:

@InProceedings{Kim_2021_ICCV,
    author    = {Kim, Kyungyul and Ji, ByeongMoon and Yoon, Doyoung and Hwang, Sangheum},
    title     = {Self-Knowledge Distillation With Progressive Refinement of Targets},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2021},
    pages     = {6567-6576}
}

Contact for Issues

License

Copyright (c) 2021-present LG CNS Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<!-- paper link -->