Simple iTorch example for visualizing CNN features as described in "Visualizing and Understanding Convolutional Networks" by Matthew Zeiler and Rob Fergus.
The implementation is quite quick-and-dirty: it seems to work, but I can't exclude the presence of methodological mistakes which by luck don't prevent the implementation to show something apparently meaningful.
- Torch 7
nnpackageimagepackage- iTorch
To run the example without modifications, you will need the OverFeat Torch wrapper from jhjin/overfeat-torch.
In short, you will need to:
- Clone the repository.
- Follow the instruction to download the weights files, and put the
net_weight_0file in themodelsdirectory (you can ignore the other files in the tgz file). - Compile the
ParamBank.cfile through the providedMakefile. - Put
ParamBank.luaand the compiledlibParamBank.soin the same directory as myvisualize_features_example.ipynbnotebook.
Also you will need to bee.jpg test image from OverFeat repository and put it into the repository root directory. However, it is straightforward to edit the notebook to choose any other picture you'd like.
You should also be able to use any other model, provided that:
- Layers are wrapped in a
nn.Sequentialcontainer. - It only has
nn.SpatialConvolutionMM,nn.SpatialMaxPooling,nn.ReLUlayers. - Convolutional layers must be proper convolutions; i.e. not 1x1 convolutions for fully-connected layers.
However, if you look at the code, you'll see easily how to adapt it for other layers. I just don't need them now.