A guided tour of the first five layers of InceptionV1,
taxonomized into “neuron groups.”
The first few articles of the Circuits project will be focused on early vision in InceptionV1
Over the course of these layers, we see the network go from raw pixels up to sophisticated boundary detection, basic shape detection (eg. curves, circles, spirals, triangles), eye detectors, and even crude detectors for very small heads. Along the way, we see a variety of interesting intermediate features, including Complex Gabor detectors (similar to some classic “complex cells” of neuroscience), black and white vs color detectors, and small circle formation from curves.
Studying early vision has two major advantages as a starting point in our investigation.
Firstly, it’s particularly easy to study:
it’s close to the input, the circuits are only a few layers deep, there aren’t that many different neurons,
Before we dive into detailed explorations of different parts of early vision, we wanted to give a broader overview of how we presently understand it. This article sketches out our understanding, as an annotated collection of what we call “neuron groups.” We also provide illustrations of selected circuits at each layer.
By limiting ourselves to early vision, this article “only” considers the first 1,056 neurons of InceptionV1.
Dmitri Mendeleev is often accounted to have discovered the Periodic Table by playing “chemical solitaire,” writing the details of each element on a card and patiently fiddling with different ways of classifying and organizing them. Some modern historians are skeptical about the cards, but Mendeleev’s story is a compelling demonstration of that there can be a lot of value in simply organizing phenomena, even when you don’t have a theory or firm justification for that organization yet. Mendeleev is far from unique in this. For example, in biology, taxonomies of species preceded genetics and the theory of evolution giving them a theoretical foundation.
Our experience is that many neurons in vision models seem to fall into families of similar features. For example, it’s not unusual to see a dozen neurons detecting the same feature in different orientations or colors. Perhaps even more strikingly, the same “neuron families” seem to recur across models! Of course, it’s well known that Gabor filters and color contrast detectors reliably comprise neurons in the first layer of convolutional neural networks, but we were quite surprised to see this generalize to later layers.
This article shares our working categorization of units in the first five layers of InceptionV1 into neuron families. These families are ad-hoc, human defined collections of features that seem to be similar in some way. We’ve found these helpful for communicating among ourselves and breaking the problem of understanding InceptionV1 into smaller chunks. While there are some families we suspect are “real”, many others are categories of convenience, or categories we have low-confidence about. The main goal of these families is to help researchers orient themselves.
In constructing this categorization, our understanding of individual neurons was developed by looking at feature visualizations, dataset examples, how a feature is built from the previous layer, how it is used by the next layer, and other analysis. It’s worth noting that the level of attention we’ve given to individual neurons varies greatly: we’ve dedicated entire forthcoming articles to detailed analysis some of these units, while many others have only received a few minutes of cursory investigation.
In some ways, our categorization of units is similar to Net Dissect
mixed3b we see many units which appear from dataset examples likely to be familiar feature types like curve detectors, divot detectors, boundary detectors, eye detector, and so forth, but are classified as weakly correlated with another feature — often objects that it seems unlikely could be detected at such an early layer.
Or in another fun case, there is a feature (372) which is most correlated with a cat detector, but appears to be detecting left-oriented whiskers!
In order to talk about neurons, we need to somehow represent them.
While we could use neuron indices, it’s very hard to keep hundreds of numbers straight in one’s head.
Instead, we use feature visualizations
When we represent a neuron with a feature visualization, we don’t intend to claim that the feature visualization captures the entirety of the neuron’s behavior.
Rather, the role of a feature visualization is like a variable name in understanding a program.
It replaces an arbitrary number with a more meaningful symbol
Although this article is focused on giving an overview of the features which exist in early vision, we’re also interested in understanding how they’re computed from earlier features.
To do this, we present circuits consisting of a neuron, the units it has the strongest (L2 norm) weights to in the previous layer, and the weights between them.
mixed3b are in branches consisting of a “bottleneck” 1x1 conv that greatly reduces the number of channels followed by a 5x5 conv. Although there is a ReLU between them, we generally think of them as a low rank factorization of a single weight matrix and visualize the product of the two weights. Additionally, some neurons in these layers are in a branch consisting of maxpooling followed by a 1x1 conv; we present these units as their weights replicated over the region of their maxpooling.
For example, here is a circuit of a circle detecting unit in
mixed3a being assembled from earlier curves and a primitive circle detector.
We’ll discuss this example in more depth later.
At any point, you can click on a neuron’s feature visualization to see its weights to the 50 neurons in the previous layer it is most connected to (that is, how it assembled from the previous layer, and also the 50 neurons in the next layer it is most connected to (that is, how it is used going forward). This allows further investigation, and gives you an unbiased view of the weights if you’re concerned about cherry-picking.
The first conv layer of every vision model we’ve looked at is mostly comprised of two kinds of features: color-contrast detectors and Gabor filters.
conv2d0 is no exception to this rule, and most of its units fall into these categories.
In contrast to other models, however, the features aren’t perfect color contrast detectors and Gabor filters.
For lack of a better word, they’re messy.
We have no way of knowing, but it seems likely this is a result of the gradient not reaching the early layers very well during training.
Note that InceptionV1 predated the adoption of modern techniques like batch norm and Adam, which make it much easier to train deep models well.
If we compare to the TF-Slim
One subtlety that’s worth noting here is that Gabor filters almost always come in pairs of weights which are negative versions of each other, both in InceptionV1 and other vision models. A single Gabor filter can only detect edges at some offsets, but the negative version fills in holes, allowing for the formation of complex Gabor filters in the next layer.
conv2d1, we begin to see some of the classic complex cell features of visual neuroscience.
These neurons respond to similar patterns to units in
conv2d0, but are invariant to some changes in position and orientation.
Complex Gabors: A nice example of this is the “Complex Gabor” feature family. Like simple Gabor filters, complex Gabors detect edges. But unlike simple Gabors, they are relatively invariant to the exact position of the edge or which side is dark or light. This is achieved by being excited by multiple Gabor filters in similar orientations — and most critically, by being excited by “reciprocal Gabor filters” that detect the same pattern with dark and light switched. This can be seen as an early example of the “union over cases” motif.
conv2d1 is a 1x1 convolution, so there’s only a single weight — a single line, in this diagram — between each channel in the previous and this one.
In addition to Complex Gabors, we see a variety of other features, including more invariant color contrast detectors, Gabor-like features that are less selective for a single orientation, and lower-frequency features.
conv2d2 we see the emergence of very simple shape predecessors.
This layer sees the first units that might be described as “line detectors”, preferring a single longer line to a Gabor pattern and accounting for about 25% of units.
We also see tiny curve detectors, corner detectors, divergence detectors, and a single very tiny circle detector.
One fun aspect of these features is that you can see that they are assembled from Gabor detectors in the feature visualizations, with curves being built from small piecewise Gabor segments.
All of these units still moderately fire in response to incomplete versions of their feature, such as a small curve running tangent to the edge detector.
conv2d2 is a 3x3 convolution, our understanding of these shape precursor features (and some texture features) maps to particular ways Gabor and lower-frequency edges are being spatially assembled into new features.
At a high-level, we see a few primary patterns:
We also begin to see various kinds of texture and color detectors start to become a major constituent of the layer, including color-contrast and color center surround features, as well as Gabor-like, hatch, low-frequency and high-frequency textures. A handful of units look for different textures on different sides of their receptive field.
mixed3a has a significant increase in the diversity of features we observe.
Some of them — curve detectors and high-low frequency detectors — were discussed in Zoom In
and will be discussed again in later articles in great detail.
But there are some really interesting circuits in
mixed3a which we haven’t discussed before,
and we’ll go through a couple selected ones to give a flavor of what happens at this layer.
Black & White Detectors: One interesting property of
mixed3a is the emergence of “black and white” detectors, which detect the absence of color.
mixed3a, color contrast detectors look for transitions of a color to near complementary colors (eg. blue vs yellow).
From this layer on, however, we’ll often see color detectors which compare a color to the absence of color.
Additionally, black and white detectors can allow the detection of greyscale images, which may be correlated with ImageNet categories (see
which detects black and white portraits).
The circuit for our black and white detector is quite simple:
almost all of its large weights are negative, detecting the absence of colors.
Roughly, it computes
NOT(color_feature_1 OR color_feature_2 OR ...).
Small Circle Detector: We also see somewhat more complex shapes in
mixed3a. Of course, curves (which we discussed in Zoom In) are a prominent example of this.
But there’s lots of other interesting examples.
For instance, we see a variety of small circle and eye detectors form
by piecing together early curves and circle detectors (
Triangle Detectors: While on the matter of basic shapes, we also see triangle detectors
form from earlier line (
conv2d2) and shifted line (