Code for the ECCV'18 paper
[Choose-Your-Neuron: Incorporating Domain Knowledge into Deep Networks through Neuron-Importance]
Ramprasaath R. Selvaraju, Prithvijit Chattopadhyay, Mohammed Elhoseiny, Tilak Sharma, Dhruv Batra, Devi Parikh, Stefan Lee
This codebase assumes that you have installed Tensorflow. If not, please follow installation instructions from here.
Download data and pretrained checkpoints using sh download.sh
and make sure the paths in the arg_config json files are correct.
You may also need to create an imagenet_files.pkl
which contains a list of (atleast) 3000 randomly sampled imagenet image paths.
python alpha2w.py --config_json arg_configs/vgg16_config_AWA.json
python alpha2w.py --config_json arg_configs/resnet_config_AWA.json
python alpha2w.py --config_json arg_configs/vgg16_config_CUB.json
python alpha2w.py --config_json arg_configs/resnet_config_CUB.json
python alpha2w.py --config_json arg_configs/vgg16_config_CUB_captions.json
python alpha2w.py --config_json arg_configs/resnet_config_CUB_captions.json
To do this, we first finetune the base model (vgg16 or resnet_v1) on a seen class images.
cd seen_pretraining/
sh cnn_finetune.sh
Change the ckpt_path
from the config_json files to the trained checkpoint (obtained from above)
Extract Neuron-Importances (alphas) from the finetuned model.
sh alpha_extraction.sh
Here we learn a transformation from domain knowledge (say attributes) to network neuron importances (alphas)
cd ..
python mod2alpha.py --config_json arg_configs/vgg16_config_AWA.json
python mod2alpha.py --config_json arg_configs/resnet_config_AWA.json
python mod2alpha.py --config_json arg_configs/vgg16_config_CUB.json
python mod2alpha.py --config_json arg_configs/resnet_config_CUB.json
python alpha2w.py --config_json arg_configs/vgg16_config_AWA.json
python alpha2w.py --config_json arg_configs/resnet_config_AWA.json
python alpha2w.py --config_json arg_configs/vgg16_config_CUB.json
python alpha2w.py --config_json arg_configs/resnet_config_CUB.json