-
pip install -r ../requirements.txt
-
Download Tiny-ImageNet from Google Drive or Dropbox. CIFAR dataset is automatically downloaded the first time the code is run. Place the dataset at your
--dir_data
directory. -
Download the model zoo from Google Drive or Dropbox. This contains the compressed models. Place the models in
./model_zoo
. -
Use the following scripts in
./scripts/dhp_camera_ready/demo_test_dhp.sh
to test the compressed models.Be sure the change the directories
--pretrain
,--dir_data
, and--dir_save
.--pretrain
: where the pretrained models are placed.--dir_data
: where the dataset is stored.--dir_save
: where you want to save the results. -
Demo: test ResNet56 with target compression ratio at about 50%.
# ResNet56, Ratio=0.5
python ../../main_dhp.py --save ResNet_DHP_SHARE_L56_Ratio50 --template CIFAR10_ResNet --model ResNet_DHP_SHARE --depth 56 --test_only \
--pretrain XXX --dir_data XXX --dir_save XXX
-
Run the scripts
dhp_XXX.sh
to reproduce the results in our paper, whereXXX
may be replaced bymobilenet
,mobilenetv2
,resnet20
,resnet56
,resnet110
andresnet164
depending on which network you want to compress. -
Be sure the change the directories
--dir_data
and--dir_save
. -
Demo: compress ResNet56 with target compression ratio 50%.
# ResNet56, Ratio=0.50
MODEL=ResNet_DHP_SHARE
LAYER=56
BATCH=64
TEMPLATE=CIFAR10
REG=3e-4
T=5e-3
LIMIT=0.01
RATIO=0.5
CHECKPOINT=${MODEL}_${TEMPLATE}_L${LAYER}_B${BATCH}_Reg${REG}_T${T}_Limit${LIMIT}_Ratio${RATIO}
python ../../main_dhp.py --save $CHECKPOINT --template "${TEMPLATE}_ResNet" --model ${MODEL} --batch_size ${BATCH} --epochs 300 --decay step-20-50+step-150-225 \
--depth ${LAYER} --prune_threshold ${T} --regularization_factor ${REG} --ratio ${RATIO} --stop_limit ${LIMIT} --print_model \
--dir_save XXX --dir_data XXX