Official implementation of Relational Knowledge Distillation, CVPR 2019
This repository contains source code of experiments for metric learning.
# If reports 'ZLIB_1.2.9' not found, you need to install as below.
wget http://www.zlib.net/fossils/zlib-1.2.9.tar.gz
tar xvf zlib-1.2.9.tar.gz
cd zlib-1.2.9/
./configure && make install
cd ..
rm -rf zlib-1.2.9.tar.gz zlib-1.2.9/
# Train a teacher embedding network of resnet50 (d=512)
# using triplet loss (margin=0.2) with distance weighted sampling.
python3 run.py --mode train \
--dataset cub200 \
--base resnet50 \
--sample distance \
--margin 0.2 \
--embedding_size 512 \
--save_dir teacher
# Evaluate the teacher embedding network
python3 run.py --mode eval \
--dataset cub200 \
--base resnet50 \
--embedding_size 512 \
--load teacher/best.pth
# Distill the teacher to student embedding network
python3 run_distill.py --dataset cub200 \
--base resnet18 \
--embedding_size 64 \
--l2normalize false \
--teacher_base resnet50 \
--teacher_embedding_size 512 \
--teacher_load teacher/best.pth \
--dist_ratio 1 \
--angle_ratio 2 \
--save_dir student
# Distill the trained model to student network
python3 run.py --mode eval \
--dataset cub200 \
--base resnet18 \
--l2normalize false \
--embedding_size 64 \
--load student/best.pth
acc | |
---|---|
RKD | Best Train Recall: 0.7940, Best Eval Recall: 0.5763 |
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》