What Does a Vision Model See Without Labels?
Foundation models trained without explicit labels learn rich representations, yet the same lack of supervision makes them difficult to interpret and validate. Fortunately, both CNNs and Vision Transformers already encode useful clues inside their intermediate features, but visualizing them directly often yields coarse heatmaps. This post explores how to extract and refine these features into sharp spatial maps that can help inspect where the model is actually focusing.
You can read the full interactive article on my blog or run the code in the companion notebook.
This journey started with my attempt to use generative adversarial networks (GANs) as feature extractors for medical images. GANs can synthesize high-quality images from random noise and provide control over the generation via latent variables, but they are not inherently invertible. I tried to address this limitation, but the approach did not work well (see my earlier post on turning StyleGAN into a latent feature extractor). Debugging that encoder-based GAN quickly became an exercise in frustration. More importantly, it exposed how few tools exist for debugging models trained without explicit annotations. The limitation is particularly relevant in self-supervised learning (SSL), where useful representations are learned directly from unlabelled data. This gap motivated me to investigate ways of deriving attribution maps for models trained without explicit labels. As part of this investigation, I found that simply averaging the feature activations produces surprisingly coherent spatial maps (Karjauv et al., 2024).
Self-Supervised Learning Meets XAI
At scale, collecting data is far easier than annotating it, which is why Self-Supervised Learning (SSL) has become so widely adopted. It lets models learn representations from unlabelled data, allowing us to reuse the features directly or fine-tune the weights for tasks like image classification or segmentation.
At the core of SSL is an encoder, a network that turns an input image into a compact set of features called an embedding. While a supervised classifier pairs this encoder with a classification head that maps the embedding to class scores, SSL methods like SimCLR and DINO train the encoder on a proxy task, such as matching different augmented views of the same image. The proxy task is only a means to learn good features. Once training finishes, the task is discarded, leaving a pretrained encoder. At sufficiently large scale, these encoders can also serve as foundation models.
The absence of labels, however, also makes it difficult to verify whether the learned representations are actually relevant for a given downstream task. For example, a model trained on images of cars may learn features related to wheels, windows, and overall vehicle shape. Some of these features may transfer well to other types of vehicles, while others may be of little use when the model is applied to bicycles or motorcycles. Without labels, it is difficult to know which properties the model has learned and how useful they will be beyond the training data. Moreover, training on random crops can lead a model to memorize unintended associations, such as which object belongs in front of a particular background. Such associations can easily go unnoticed, and evaluating them is non-trivial (Meehan et al., 2023).
This is where explainable AI (XAI) would seem useful. For supervised models, methods such as Grad-CAM can highlight image regions that contribute to a particular prediction. Occlusion methods such as RISE take a different route: they repeatedly mask parts of the input and observe how the target prediction score changes.
For an SSL encoder, however, there may be no prediction score to explain. The model produces an embedding, and its individual dimensions usually have no predefined semantic meaning. We do not know that one feature represents a wheel, another a window, or another the shape of a car. Asking for the importance of a pixel for the class “car” therefore makes little sense when there is no car score in the first place.
There have been attempts to adapt XAI to label-free models. One such attempt is RELAX (Representation Learning Explainability), which extends the supervised occlusion method RISE. Instead of asking how masking part of an image changes a class score, we can ask how much the masking changes the representation. The original image provides a reference embedding. Masked versions of the image are passed through the same encoder, and their embeddings are compared with the reference using cosine similarity. If masking a region substantially changes the representation, that region was probably important to the encoder.
The idea is simple, but it comes at a cost. RELAX requires many masked versions of each image and therefore many forward passes through the model, while the resulting maps can be noisy. More generally, masking itself is not entirely innocent. Hiding parts of an image with a solid colour creates inputs that differ from what the model normally sees, so part of the response may come from the perturbation.
From Class-Specific to Label-Free Activation Maps (LaFAM)
One useful property of CNNs is that their convolutional feature maps retain a spatial layout. Each convolutional layer produces a collection of activation maps (also called feature maps), one per feature channel. Each map records how strongly a learned feature responds at different spatial locations. We can trace that response back to roughly the same region in the input. This spatial structure is what makes methods such as class activation maps (CAMs) possible.
In the original CAM formulation, the classifier assigns a different weight to each feature channel for each class. To explain a prediction such as car, CAM reduces the stack of spatial activation maps to a single heatmap using the weights associated with the car class. Features that are strongly associated with that class contribute more to the resulting heatmap. Grad-CAM generalizes this idea by using gradients to estimate how important each feature map is for a chosen target. In other words, the activation maps tell us where a feature responds, while the class-specific weights tell us which features matter for the target.
But what if there is no class to explain? We can take a surprisingly simple approach. Instead of finding class-specific weights, we give every feature channel equal weight and average the activations across channels at each spatial location. In the ResNet-50 models evaluated in the LaFAM paper (Karjauv et al., 2024), the final activations come out of a ReLU, which sets negative responses to zero. Positive and negative values therefore cannot cancel when averaged. A location receives a high value when many high-level features respond there, or when a smaller number respond particularly strongly. While CAM asks the classifier which feature maps matter and then combines them accordingly, averaging simply lets every feature map vote equally.
What About Vision Transformers?
ViTs come with a tempting visualization: attention. We can inspect how image patches attend to one another and map those interactions back onto the image. In self-supervised models such as DINO, attention maps can even reveal surprisingly clear object structure without segmentation labels. But attention tells us how tokens exchange information, not necessarily which parts of the image are responsible for the representation we want to inspect. So what happens if we leave attention aside and look at the token representations themselves?
A ViT divides an image into patches and represents each patch with a token. The tokens are processed as a sequence and exchange information through self-attention, so a token in a deep layer no longer describes only its own patch. Still, every patch token has a known spatial address in the original image, which means we can arrange them back into their original grid. Many ViTs, such as the supervised ViT and CLIP, are trained through an extra class token, and only that token reaches the classifier. Even so, the patch tokens preserve where things are in the image (Raghu et al., 2021), and we can read this information from them. This gives us something similar to a CNN feature tensor. In a CNN, each spatial location contains a vector of channel activations. In a ViT, each patch contains a token vector, and we call its entries channels as well. Reduce each token to a single value, put the values back into the patch grid, and we get a coarse heatmap.
The reduction itself requires a choice. Unlike the ReLU outputs of a ResNet, ViT tokens are signed, and so are the features of modern CNNs such as ConvNeXt. Individual channels also have no predefined semantic meaning. Different features may respond to objects, object parts, textures, or surrounding context. Collapsing them into a single value therefore produces a summary of where the representation is active. Here, we apply ReLU before averaging, which keeps the positive responses and prevents them from cancelling against negative ones. We use this same reduction for every model below, so the maps show where positive feature responses are strongest. It is not the only reasonable choice, and it does not work equally well for every encoder, as we will see further below.
Results
The grid above shows label-free heatmaps from a supervised ConvNeXt for five images, containing several objects. When a scene contains more than one object, the map does not pick a winner. The dog and the cat both light up, and so do both dogs and all six objects. With no class to choose, every object the encoder responds to strongly stays in the map.
The limitation is just as easy to see. ConvNeXt, like ResNet-50, ends with a 7×7 grid of features. The response is already informative, but it is coarse. Nearest-neighbour resizing shows it as large tiles, and bilinear resizing would only blend their edges.
A Finer Picture
The coarse grid comes from the encoder itself. CNNs progressively downsample the image, and ViTs cut it into fixed-size patches. To obtain a finer map, we can either upsample the features with AnyUp or propagate the activations back to the input using LRP. Both approaches increase spatial detail, but they do so in very different ways.
AnyUp (Wimmer et al., 2025) is a pretrained feature upsampler designed to work with features from different vision encoders. It takes low-resolution features together with the corresponding higher-resolution image and upsamples the feature tensor to the image resolution. During training, the encoder’s features for a small crop serve as a finer-scale target for the same region of the full image, so AnyUp learns to predict what the features would look like at a higher resolution. The image provides spatial guidance that ordinary interpolation does not have.
For example, ConvNeXt turns a 3×224×224 RGB image into a 1024×7×7 feature tensor. We can give AnyUp this tensor together with the image, and it produces a 1024×224×224 feature tensor. We can average its channels in the same way as before to obtain a full-resolution heatmap. Under the hood, every output feature vector is a weighted average of the coarse feature vectors in a small window around it, with the weights computed by attention between the image pixels and the coarse features. When the features are already non-negative, as in a ResNet, the same holds for the heatmap, since averaging over channels is linear as well. Each pixel of the refined map is then a weighted average of nearby cells of the coarse map. AnyUp decides where the boundaries between them run, but it cannot create a response the coarse map does not have.
Layer-wise relevance propagation (LRP) (Bach et al., 2015; Montavon et al., 2018) takes a different approach. Instead of increasing the resolution of the feature tensor, it traces relevance backward through the encoder. At each layer, relevance is redistributed to the preceding neurons according to a chosen propagation rule until it reaches the input, producing a pixel-level attribution map (see my post on LRP for the full breakdown).
LRP was originally designed to explain predictions from supervised models by redistributing the relevance of a target output back to the input. But nothing prevents us from choosing a different starting signal. Instead of a class score, we start from the encoder’s features themselves. We place a fixed amount of relevance on the feature tensor and let LRP carry it back to the pixels. Each feature value receives a share in proportion to how strongly it is active, so inactive features start with nothing. This is the same quantity the averaged map shows, but traced back to the input. The resulting map shows which input pixels the propagation connects to the active features at the chosen layer.
The figure below compares seven architectures across Averaging, AnyUp, and LRP:
The Averaging column is blocky by construction, since each block is one feature cell. An object shows up as a cluster of bright blocks that spills over its edges into the background. AnyUp keeps that pattern but redraws it to follow the image. The blocks around the dog and the cat become two sharp silhouette. Each object comes out filled in almost evenly, with a sharp border wherever the image has one. The glow that spills into the background can come from three places:
- At 7×7, a cell on the edge of an object covers part of the object and part of the background.
- Each cell sees more of the image than its own square. In a CNN, each feature is computed from a wider receptive field around it, and in a transformer, attention lets each token gather information from other tokens. A patch of grass next to a dog can therefore carry information about the dog.
- The background can matter in its own right. Grass, trees, and sky are things an SSL model can learn to recognize, just like dogs. The background may also serve as a shortcut, as when a model learns to expect a dog wherever it sees a lawn.
AnyUp cannot tell these cases apart. Each refined value is a weighted average of nearby coarse values, so AnyUp keeps whatever the coarse map contains and only gives it sharper edges.
LRP shows a different picture. Its relevance concentrates on image structures such as contours, object parts, and internal edges, and little of it reaches the background for supervised models. The maps are sparse, and they are not free of artifacts either. The CNN attribution maps are generally spatially continuous, whereas transformer-based models show visible block structure in some of the images. The plain ViTs show blocks the size of their patches, and for MAE a regular grid dominates much of the relevance map. Producing a pixel-level attribution map therefore does not completely remove the spatial constraints introduced by patch embeddings or by the chosen propagation rules.
One caveat is that the zennit library provides built-in support mainly for VGG and ResNet architectures. ConvNeXt and ViTs contain operations for which additional propagation rules must be implemented, as others have done for transformers (Achtibat et al., 2024). If you want to learn more about these rules and how much they change the attributions, my post What LRP Is and Why It Fails Quietly on Modern Vision Models goes through them in detail.
A Watermark in the Web
The spider web image holds a small surprise. In its bottom-right corner sits a tiny sparkle, the watermark of the image generator that created the picture. It covers less than one percent of the image and is easy to miss, but several encoders do not miss it. Subtle artifacts like this often trigger unpredictable behaviour and out-of-distribution failures across deep learning models. Catching them early is precisely what makes label-free maps so useful for debugging.
The two methods reveal it in different ways. For CLIP ConvNeXt, the watermark’s cell is the brightest of all 49 cells in the averaged map, and LRP places about five percent of the relevance on it. MaxViT barely reacts to the watermark in the averaged map, but its LRP map puts almost eight percent of the relevance there, with a peak about four times higher than anywhere else. Since every map is scaled by its own maximum, that single spot turns the rest of the MaxViT map nearly black.
Once we know about the watermark, we can set it aside and look at the rest. For CLIP ConvNeXt, it is enough to leave the watermark’s cell out of LRP’s starting amount. The share on the watermark then drops from five to about two percent, and the centre of the web becomes visible, although the map stays noisy. For MaxViT, the same step changes almost nothing, because relevance reaches the watermark from cells across the whole image, even from the opposite corner. Only when the map is scaled without the watermark does it become clear that the threads of the web were there all along.
The example also shows where the maps stop. They tell us where the representation responds, but not what the response is about. We recognized the watermark because we looked at the image ourselves. To the maps, it is just another bright region, like the web. Telling such responses apart without labels requires asking the representation something else, for instance which parts of an image it treats as alike.
When ReLU Is Not Enough
The earlier comparisons included three plain vision transformers , DINOv1, DINOv3 and MAE, and their maps behave much like those of the CNNs. For three other plain ViTs, a supervised ViT-B/16, a CLIP ViT-B/16 and DINOv2, the same reduction fails. Their maps are bright almost everywhere apart from a handful of much darker tokens, and the objects are hard to find.
What sets the two groups apart? The obvious suspect is the ReLU, but it does not throw most of the values away. In every plain ViT we looked at, about half of all feature values are positive, just as in the CNNs. Two other differences stand out:
- The dark tokens: All three encoders that fail have some dark outlier tokens in the background of every image, while DINOv1, DINOv3 and MAE have none. Such outlier tokens are a known effect in ViTs (Darcet et al., 2024; Sun et al., 2024). Darcet et al. found them in DINOv2, supervised ViT, and OpenCLIP, but not in DINOv1, and showed that a few extra tokens (registers) remove them (DINOv3 includes four such registers). Heatmaps stretch between their darkest and brightest tokens, so these few dark tokens consume most of the color scale, leaving all other tokens washed out bright.
- Channels that never switch off: In a CNN, a channel is typically active in some parts of the image and inactive in others. In a ResNet, inactive means zero, and in ConvNeXt it means negative. In the supervised ViT and CLIP, between one channel in eight and one in six stays positive across almost the whole image, and these channels are strongest on the background. The ReLU passes them unchanged, pulling the map toward the background.
The remedy is to centre each channel before ReLU by subtracting its mean across all tokens in the grid. The channel is then positive exactly where it is higher than average in this image, regardless of its overall level. For the three encoders that failed, centring helps dramatically, though maps remain noisy. In the image of the dog and cat above, both animals stand out clearly for CLIP and DINOv2, while the supervised ViT shows the cat clearly and the dog faintly.
Limitations
Resolution. The heatmap produced by averaging can only be as sharp as the feature grid being averaged (7×7 for CNNs, 14×14 for ViT-B/16). On a 224×224 input, one cell of a 7×7 grid spans 32×32 pixels. Small objects may disappear into a single cell, and nearby objects merge. Both refinements add detail, but each brings its own assumptions:
- AnyUp borrows detail from the image. It aligns coarse responses with sharp boundaries, but cannot verify whether those boundaries reflect evidence the encoder actually used. A background response can look just as precise as an object.
- LRP derives detail from the network’s own computation, but the result depends on where relevance starts and which propagation rules carry it. LRP deliberately allows different rules, and these choices visibly change the maps.
Semantic Ambiguity. Averaging collapses the feature dimension into a single scalar per spatial location. This provides a useful spatial summary, but discards information about which features produced the response. Two bright regions may be driven by entirely different features, and the map cannot distinguish an object from a background texture if both activate strongly.
Furthermore, applying ReLU before averaging discards negative responses, which breaks on certain encoders unless channels are centred first. Alternative reductions (signed average, absolute magnitude, vector norm) emphasize different properties and produce different maps.
Averaging across feature channels is almost embarrassingly simple and requires no prediction target. Yet in complex scenes, even supervised models trained with one label per image produce label-free maps that highlight multiple objects, capturing far more local structure than a single class prediction can express.
In supervised classifiers with global average pooling and a linear head, the math works out cleanly. Applying the linear classification layer to the averaged embedding gives the exact same logits as averaging the spatial logits across locations. Beneath its single prediction, the model quietly acts as a multiple-instance learner (Karjauv, 2026).
SSL models are trained very differently, but they also preserve spatial features before pooling them into a single embedding. It is still speculative, but that aggregation step may induce a similar implicit multiple-instance mechanism.
At the same time, training without labels introduces a new challenge. When a heatmap lights up, what is the model actually responding to? A strong response does not guarantee task importance. The resulting map reveals only where the representation responds, not what it represents. Recovering those underlying semantics requires a different approach, which we will leave for another time.
