Revisiting the Efficient Channel Attention paper (2019, 12k citations) - the central hypothesis isn't quite right [D]
ECA was positioned as a successor to SE . The idea behind ECA is quite simple. Unlike SE which reduces the channel means into a smaller hidden layer, it directly uses a 1d convolution kernel on the channel means themselves, avoiding the need for dimensionality reduction. The results are undeniable: ECA is a clear improvement over SE. The authors claim that cross-channel interaction is a key ingredient. But on a conceptual level, the design of ECA doesn't make much sense. Let's take a step back. Why do we use convolutions in the first place? Convolutions are fundamentally designed for data with an underlying topology (e.g. space or time). They assume locality (adjacent elements interact) and translation invariance (the same kernel applies everywhere). Sliding a kernel across a 2D image works because coordinates have meaning, and the statistical properties of an image are largely stationary across the frame. This isn't perfectly true - which is why modern CNNs have moved towards dynamic convolutions - but it's still good enough to be useful. If you randomly permuted the pixels in an image, a convolution would be meaningless. Now consider tabular data. Suppose we have 32 channels e.g. [cost, weight, material, colour, volume, speed, ...]. Using a CNN architecture for this kind of data is clearly inappropriate. A 1d kernel of width 3 would be moved across the channels, so that [cost, weight, material] was input and also [ weight, material, colour] was input and so on, and have to somehow output something meaningful. ECA is doing exactly this type of computation. ECA does a 1d convolution over the channel dimension. It is a cursed convolution because tabular data does not have a topology to suit it. In practice, if you did use a CNN on tabular data, I would expect better than random performance because neural networks are ridiculously good at fitting to the dataset given their constraints and would reorganise the channel order (using the initial 1x1 projection layer) to suit it. It would learn to use convolutions, but it would be an inefficient approach. Experiments Instead of using image data, I used chess data: the 6-piece endgame tablebases for chess . Chess is a solved game with 6 (or fewer) pieces on the board. The task for the network is this: given a position, with perfect play is it a win, draw or loss for the active player? A CNN architecture is what lc0 originally used (where at the time, surpassed Stockfish to become the strongest chess engine) so it is very suitable for this task. Chess tablebases are useful for benchmarking architectural designs because training examples can be sampled from the complete underlying problem rather than from an incomplete dataset. This differs from datasets such as the CIFAR-10 image dataset, where the train set is not expected to be a random unbiased sample from the true full distribution - we might unknowingly have a disproportionately have pictures of frogs on sunny days. Even when we don't train on each of the 3.7 trillion 6-piece positions, we know that we've randomly sampled from those positions, meaning we don't train on a biased subset - we can be confident our training samples are representative of the full set. Experiment results. Each channel gate row is the average of 3+ separate runs. Channel gate Avg test loss Avg test accuracy IdentityGate 0.0981 96.04% SqueezeExcitationGate (SE8) 0.0954 96.17% EfficientChannelAttentionGate (k=3) 0.0822 96.68% EfficientChannelAttentionGate (k=1) 0.0826 96.61% CenterMaskedEfficientChannelAttentionGate (k=3) 0.0821 96.63% PerChannelGate 0.0815 96.65% IdentityGate Unsurprisingly, no squeeze performed the worst of all tests. SqueezeExcitationGate SE showed a modest improvement. EfficientChannelAttentionGate (k=3) ECA, consistent with the paper, showed a clear improvement over SE. EfficientChannelAttentionGate (k=1) Surprisingly, this had good results indicating that their central hypothesis that cross-channel interaction is key wasn't quite right CenterMaskedEfficientChannelAttentionGate: ECA with k = 3 with the middle channel masked (in a [1, 0, 1] mask) This complicates the story, it indicates cross channel attention can actually be useful. PerChannelGate Instead of a convolution kernel that slides across the axis, simply use a separate independently specified weight per channel. This has one parameter per channel, more than the 3 parameters of ECA With k=3, but it is still a negligible amount since per layer we expect on the order of num_channels2 parameters. For clarity and to avoid ambiguity, here is the code for the key squeezes. So basically there's 3 tiers of results. No squeeze with poor results, SE With mediocre results, and the rest ECA-like with the best results. So something weird is going on. I don't have a good explanation for the results (in particular the success of the [1, 0, 1] mask), and I am currently trying to find one. One suspicion I have is that in the 101 mask, the net is smart enough to smuggle information into the global means of channel A and C to help with channel B without affecting normal channel operation (by using biases to undo its shift of the global mean), but have not yet tested this hypothesis. There's a lot of possibilities. The good news is the weight count is very low - only 3 with k=3, so manually inspecting the weights can be useful. In my digging, I some repositories that recreate the original ECA. Not one of them tests the k=1 case, which would have revealed that the explanation of the mechanism is not correct. The official repo does use k=1 but only for a limited number of early layers, then moves to k=3 for the rest. Repository Permits / Uses $k=1$? Trained $k=1$ Ablation? Result / Notes BangguWu/ECANet (Official) Yes. MobileNetV2 uses $k=1$ when $C < 96$, else $k=3$ Partial. Mixed $k={1,3}$ in MobileNetV2; no pure $k=1$ ResNet ablation 72.56 Top-1 / 90.81 Top-5 on ImageNet Reproducibility-Challenge-ECANET Generic formula can yield $k=1$, but not at standard test widths No. No independent $k=1$ run found None huggingface/pytorch-image-models (timm) Can be manually set to $k=1$, but adaptive formula clamps $k \ge 3$ No. No official $k=1$ benchmark None It's interesting that the k=1 case, a 1 parameter approach, outperforms SE, CBAM and matches ECA. It definitely makes me wonder if we're over-engineering networks today in some way. My final thoughts: The paper and repos should have tested the "degenerate" kernel size of 1, which has no cross channel interaction. At k=1, ECA still beats SE, undermining their central hypothesis. They spent an enormous amount of time fine tuning the exact optimal value of k, without taking the scientific approach of trying to disprove their hypothesis. In addition to traditional real-world datasets, architectures should also be tested on synthetic datasets where we have full access to the complete dataset (e.g. chess endgame data) so that we can better separate incidental regularization improvement effects with core architectural efficiency effects - the idea being that there is no risk of overfitting when we have access to a complete, flawless dataset. If the real reason a new architecture works well on real-world data is because of implicit regularization, it won't show the same improvements on the synthetic dataset.