Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.

Guided feature inversion

PyTorch code for paper: Towards Explanation of DNN-based Prediction with Guided Feature Inversion. It has been accepted in KDD2018.

We propose a guided feature inversion method to provide instance-level interpretations of CNN predictions. The proposed method could locate the salient foreground part, thus determining which part of information in the input instance is preserved by the CNN, and which part is discarded.

Usage Instructions:

  • Clone the code from Github:
git clone
cd guided-feature-inversion
  • Provide explanation to a CNN prediction for an input image. Here we use VGG-19, for both l0 and l1 layer, we use pool5 layer. The explanation is for the prediction with the largest probability.
python --layer features.36 --epochs 80 --gpu 0 --network vgg19 --label 1 --image ILSVRC2012_val_00000021.JPEG
  • By replacing the --label with other categories, this framework also could provide explanations for different classes of objects.

  • This framework can also give explanations for other CNN architectures, such as AlexNet, and ResNet, by replacing with appropriate network --network and layer --layer.

System requirement:

Python 2.7, torch 0.3, torchvision, matplotlib, PIL, cv2, and skimage.


This work is motivated by the feature inversion paper Understanding deep image representations by inverting them, and the feature inversion implementation.


    author    = {Mengnan Du, Ninghao Liu, Qingquan Song, and Xia Hu},
    title     = {Towards Explanation of DNN-based Prediction with Guided Feature Inversion},
    booktitle = {The 24rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD)},
    year      = {2018}


PyTorch code for KDD 18 paper: Towards Explanation of DNN-based Prediction with Guided Feature Inversion






No releases published


No packages published