← all repositories
utkuozbulak/pytorch-cnn-visualizations

Fifteen ways to ask a neural network 'why'

Because explaining a neural network's hunch shouldn't require switching frameworks or deciphering a monolithic codebase.

pytorch-cnn-visualizations
Not currently ranked — collecting fresh signals.
star history

What it does This repository bundles roughly fifteen CNN visualization techniques—from vanilla backpropagation and Grad-CAM to Deep Dream and layerwise relevance propagation—into standalone PyTorch scripts. Each method lives in its own file (e.g. gradcam.py) with shared image handling tucked away in misc_functions.py, making it easy to compare how different algorithms highlight the regions that nudge a model toward “king snake” or “mastiff.” It targets pretrained AlexNet and VGG from the model zoo, preprocessing everything with standard ImageNet normalization.

The interesting bit The value is in the side-by-side layout: you get saliency maps, activation heatmaps, and guided backpropagation variants all in one place, as if someone turned a scattered literature review into a single, comment-heavy codebase. It is essentially an interpretability Rosetta Stone for classical CNN architectures.

Key highlights

  • Covers gradient-based (Grad-CAM, Integrated Gradients) and gradient-free (Score-CAM) methods, plus filter visualization and inverted representations.
  • Runs on CPU by default; the author notes GPU acceleration takes “very little effort” except for the oversized Deep Dream example.
  • Heavily commented code aimed at readability and educational porting rather than production packaging.
  • One technique per file, so you can lift just the saliency or CAM logic you need without untangling a framework.

Caveats

  • The code is pinned to PyTorch 0.4.1; the author explicitly warns that later torch versions may break some functions and has “no plans at the moment” to upgrade.
  • A recent migration from cv2 to PIL left a few things potentially broken, though the author tested all methods.
  • Porting to custom models requires editing model.features and model.classifier assumptions hard-coded for AlexNet/VGG-style splits.

Verdict Grab this if you are a researcher or student who wants to compare classic CNN interpretability methods without jumping between disparate repositories and frameworks. Skip it if you need a maintained, model-agnostic library for modern architectures or production pipelines.

Frequently asked

What is utkuozbulak/pytorch-cnn-visualizations?
Because explaining a neural network's hunch shouldn't require switching frameworks or deciphering a monolithic codebase.
Is pytorch-cnn-visualizations open source?
Yes — utkuozbulak/pytorch-cnn-visualizations is open source, released under the MIT license.
What language is pytorch-cnn-visualizations written in?
utkuozbulak/pytorch-cnn-visualizations is primarily written in Python.
How popular is pytorch-cnn-visualizations?
utkuozbulak/pytorch-cnn-visualizations has 8.2k stars on GitHub.
Where can I find pytorch-cnn-visualizations?
utkuozbulak/pytorch-cnn-visualizations is on GitHub at https://github.com/utkuozbulak/pytorch-cnn-visualizations.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.