zennit-crp

Generate concept-conditional relevance heatmaps and feature visualizations for PyTorch models using CRP.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill zennit-crp-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zennit-crp
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/mechanism-skills/multi-modal/zennit-crp
Command: npx skills add https://github.com/zjunlp/Mechanist --skill zennit-crp-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zennit-crp, zennit, torch, torchvision, numpy, pillow, and includes scripts (resource) components.

What problem does it solve? Standard attribution maps show where a model looks but not which latent concepts drive its predictions. This Skill applies Concept Relevance Propagation (CRP) to isolate individual channel concepts in PyTorch networks, producing concept-conditional heatmaps, relevance-ranked concepts, and representative reference images. ## Core Features & Use Cases - Conditional Attributions (CRP): Mask relevance flows during backpropagation to compute heatmaps conditioned on specific channels and output classes via CondAttribution and ChannelConcept. - Relevance/Activation Maximization: Use FeatureVisualization to precompute RelMax or ActMax reference images showing which dataset samples best represent each neuron or channel. - Attribution Graphs & Concept Statistics: Trace relevance through model layers and rank channel-level importance across Conv2d and Linear layers. - Use Case: Given a pretrained VGG16, identify the top-5 most relevant channels in features.40 for a prediction, then retrieve and crop their RelMax reference images for embedding into CLIP or DINOv2 to auto-label each neuron with a semantic concept. ## Quick Start Run the conditional attribution demo script to compute a CRP heatmap for channels 50 and 100 in layer features.28 of a pretrained VGG16 model.

Frequently Asked Questions about zennit-crp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute concept-conditional heatmaps with zennit-crp?

Create a CondAttribution object for your model, define conditions mapping layer names to channel IDs plus an output class, and call attribution with a zennit composite like EpsilonPlusFlat. The result provides heatmap, prediction, and per-layer relevances and activations.

What is the difference between RelMax and ActMax in feature visualization?

RelMax selects dataset samples that maximize a concept's relevance to the model's classification decision, while ActMax selects samples that most strongly activate the unit. RelMax is more faithful for explanations, especially in adversarial scenarios.

Does zennit-crp work with Vision Transformers?

CRP through self-attention is not implemented in zennit-crp, so ViT support is limited. A fallback is to use the upsampled spatial-token activation map as a heatmap proxy, though it is an activation map rather than true relevance.

Why should BatchNorm be merged before running LRP attribution?

BatchNorm layers can cause numerically unstable relevance propagation. Including SequentialMergeBatchNorm in the canonizers list folds BatchNorm parameters into preceding Conv or Linear layers, ensuring stable LRP results.

How do I crop CRP reference images for CLIP or DINOv2 embedding?

Blur the heatmap with a Gaussian kernel scaled to the encoder resolution, normalize by max, threshold at 1 percent of peak relevance, and extract a square bounding box. This gives the foundation model enough context to embed the concept rather than background noise.