Back to paper library
Paper notesarXiv 2020CVPR 2020

RegNet

Do Good Architectures All Look Alike?

Original paper

Designing Network Design Spaces

Paper authors

Ilija Radosavovic · Raj Prateek Kosaraju · Ross Girshick · Kaiming He · Piotr Dollár

Publication
CVPR 2020Conference
First submitted to arXiv
arXiv:2003.13678
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{classiccnnsregnet2020,
  title = {{Designing Network Design Spaces}},
  author = {Ilija Radosavovic and Raj Prateek Kosaraju and Ross Girshick and Kaiming He and Piotr Dollár},
  year = {2020},
  eprint = {2003.13678},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.13678}
}
On this page

Around 2019, one of the hottest ways to design convolutional networks was neural architecture search (NAS). You define a search space and let an algorithm find the best network within it; that's how NASNet and EfficientNet came about.

The networks found this way are strong, but what we get is a single network, a set of numbers tuned for one level of compute and one kind of hardware. Why does it look like this? How should it change for a different level of compute? The search result itself can't answer that.

Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollár of Facebook AI Research wanted to take a different approach. Instead of designing a single network, they design “network design spaces,” finding design principles in how a large population of networks performs.

Defining the Problem

What Manual Design and NAS Each Lack

Look back at LeNet, AlexNet, VGG, and ResNet. These hand-designed networks left behind more than models; they also left principles such as using convolution, scaling up data and networks, going deeper, and adding residuals. These principles carry over to many new settings. The trouble is that once there are many design choices, it gets very hard to find the best combination by trying them one by one by hand.

NAS solves the “trying” problem, but what it produces is a network instance tuned for a specific setting. What the authors want are networks that are simple, easy to understand, and generalize to different settings, along with the principles behind them.

As for different compute requirements, the common practice is to take one network and scale its depth, width, or resolution by some rule, with EfficientNet's compound scaling as one example. But that still starts from a single network.

How to Compare Two Design Spaces

If what you're designing is “a population of networks,” you need a way to compare how good one population is against another. The authors use a tool that Radosavovic et al. proposed the year before, which randomly samples nn models from a design space, trains them all, and looks at the distribution of their errors.

Concretely, the tool is the error empirical distribution function (EDF):

F(e)=1n∑i=1n1[ei<e].F(e)=\frac{1}{n}\sum_{i=1}^{n}\mathbf{1}[e_i<e].

F(e)F(e) is simply “the fraction of models with error below ee.” The closer the curve is to the upper left, the more good models the space contains.

On the left, three nested ellipses: the outermost blue one is A, the middle orange one B, and the innermost yellow one C, with arrows pointing from A to B and then to C. On the right, three cumulative probability curves, with error (40 to 60) on the horizontal axis and cumulative probability (0 to 1) on the vertical axis. Blue A is the flattest and furthest right; orange B shifts to the left; yellow C is furthest left and steepest
Figure 1 from the paper, excerpted from page 1 of the v1 PDF. Design space design: each step shrinks space A into a simpler or better B, then C; on the right are the error EDFs of all three.

The left panel shows the authors' process. Starting from a very large space A, each step adds one constraint, giving a smaller B and then C. The right panel shows the EDF obtained by sampling and training models from each of the three spaces; C's curve is furthest left, meaning its models are the best overall.

Comparing whole distributions is more robust than comparing only the best model found in each of two spaces. The authors also hope that principles holding for a whole population of models stand a better chance of generalizing to other settings.

Sampling and training hundreds of models is expensive. The authors do their design in a “low-compute, short-training” regime, with each model at about 400 million multiply-adds (400MF), trained for only 10 epochs on ImageNet. At that scale, training 100 models takes about as much compute as training one ResNet-50 for 100 epochs.

Solving the Problem

The Starting Point: AnyNet

The authors begin with a very unconstrained design space called AnyNet. A network has three parts. The stem is a single stride-2 3×33\times3 convolution with 32 channels; the head is average pooling plus a fully connected layer; the body in the middle is where the action is, with 4 stages that halve the resolution one after another, each made of several identical blocks.

The block is a ResNeXt-style residual bottleneck with grouped convolution, which the authors call the X block:

Diagram of the X block. (a) The stride-1 version: input wi, ri, ri passes through a 1x1 s=1 convolution to become wi/bi channels, then a 3x3 grouped convolution with group width gi, s=1, then a 1x1 s=1 convolution back to wi channels, and is finally added to the shortcut on the right. (b) The stride-2 version: the middle 3x3 convolution has stride 2, and the shortcut gains a 1x1 s=2 convolution
Figure 4 from the paper, excerpted from page 4 of the v1 PDF. The X block: a 1×11\times1 convolution, a 3×33\times3 grouped convolution, and a 1×11\times1 convolution, each followed by BN and ReLU.

Each stage ii has four tunable parameters:

  • Number of blocks did_i
  • Block width wiw_i: the number of output channels
  • Bottleneck ratio bib_i: the middle layer has wi/biw_i/b_i channels
  • Group width gig_i: the number of channels in each group of the 3×33\times3 grouped convolution

Four stages with four parameters each make 16 degrees of freedom. The sampling ranges are di≤16d_i\le16, wi≤1024w_i\le1024 and divisible by 8, bi∈{1,2,4}b_i\in\{1,2,4\}, and gi∈{1,2,…,32}g_i\in\{1,2,\ldots,32\}, which together give about 101810^{18} possible networks. The input is fixed at 224×224224\times224.

Rather than searching these 101810^{18} networks for the single best one, the authors add constraints step by step, and each step has to make the space simpler and easier to understand without reducing the number of good models.

Narrowing It Down Step by Step

Each time they add a constraint, the authors sample and train 500 new models to see whether the EDF gets worse:

Table: Combination counts compiled from Table 1 of the paper; error rates from the legends of Figures 5, 7, and 9. ImageNet top-1 error (%) at 400MF with 10 epochs of training.
SpaceNew constraintDegrees of freedomCombinationsMin / mean error
AnyNetXA_ANone16∼1.8⋅1018\sim1.8\cdot10^{18}39.0 / 49.0
AnyNetXB_BAll stages share bb13∼6.8⋅1016\sim6.8\cdot10^{16}39.0 / 49.2
AnyNetXC_CAll stages share gg10∼3.2⋅1014\sim3.2\cdot10^{14}38.9 / 49.4
AnyNetXD_Dwi+1≥wiw_{i+1}\ge w_i10∼1.3⋅1013\sim1.3\cdot10^{13}38.7 / 43.2
AnyNetXE_Edi+1≥did_{i+1}\ge d_i10∼5.5⋅1011\sim5.5\cdot10^{11}38.7 / 42.7
RegNetXQuantized linear6∼3.0⋅108\sim3.0\cdot10^{8}38.2 / 41.0

The first two steps make all stages share the same bb and gg, removing 6 degrees of freedom while leaving the EDF almost unchanged, which shows that these two parameters don't need to be tuned separately for each stage.

The third step comes from observation. The authors plotted a few good and a few bad networks from AnyNetXC_C and found that the good networks all get wider toward the end. Adding the constraint wi+1≥wiw_{i+1}\ge w_i drops the mean error from 49.4% to 43.2% in one go, and the best model doesn't get any worse. The fourth step, di+1≥did_{i+1}\ge d_i, improves the results a little more.

At this point, the space has shrunk by a factor of more than three million, and the good models are more concentrated than ever.

Width Is a Straight Line

Next, the authors plot the 20 best models from AnyNetXE_E on a single chart, with the block index on the horizontal axis and the block width on the vertical axis:

Top left: 20 gray staircase curves showing the per-block widths of the 20 best models (log-scale vertical axis), with a smooth black curve running through the middle of them. Top middle and right: each shows one good model's actual widths (solid blue staircase), a linear fit (dotted line), and the quantized fit (dashed staircase), with the two staircases nearly overlapping. Bottom row, three scatter plots: fitting error efit versus error for every model in AnyNetXC, AnyNetXD, and AnyNetXE; the good models all cluster where efit is near 0, and from C to E the points gather further and further to the left
Figure 8 from the paper, excerpted from page 5 of the v1 PDF. The widths of good models can be described by a quantized linear function; models with a large fitting error efite_\text{fit} also tend to have higher error.

In the top-left chart, every model's gray staircase is different, but the overall trend can be described by a very simple straight line, wj=48⋅(j+1)w_j=48\cdot(j+1), which is the black curve (the vertical axis is logarithmic, so it looks bent).

The line gives every block a different width, but in a real network, all the blocks in a stage share the same width, forming a staircase. The authors turn the line into a staircase with three equations.

First, a straight line gives each block a continuous width:

uj=w0+wa⋅j,0≤j<d.u_j=w_0+w_a\cdot j,\qquad 0\le j<d.

w0w_0 is the initial width, waw_a is the slope, and dd is the total number of blocks. Next, a parameter wmw_m is introduced, and uju_j is written as w0w_0 times some power of wmw_m:

uj=w0⋅wmsj.u_j=w_0\cdot w_m^{s_j}.

Finally, the exponent sjs_j is rounded:

wj=w0⋅wm⌊sj⌉.w_j=w_0\cdot w_m^{\lfloor s_j\rceil}.

Once the exponents are integers, the widths can only take a few values, w0w_0, w0wmw_0w_m, w0wm2w_0w_m^2, and so on; the blocks with the same width form a stage, so wmw_m is the width multiplier between adjacent stages.

Let's actually compute it for RegNetX-1.6GF. Its parameters in torchvision are d=18d=18, w0=80w_0=80, wa=34.01w_a=34.01, wm=2.25w_m=2.25, and group width g=24g=24:

Python
import math

d, w0, wa, wm, g = 18, 80, 34.01, 2.25, 24        # RegNetX-1.6GF

u = [w0 + wa * j for j in range(d)]                 # Eq. (2): a continuous width for each block
s = [math.log(uj / w0) / math.log(wm) for uj in u]  # Eq. (3): convert to the exponent in w0 · wm^s
w = [w0 * wm ** round(sj) for sj in s]              # Eq. (4): round the exponent, turning the widths into a staircase
w = [round(wj / 8) * 8 for wj in w]                 # round widths to multiples of 8

for j in (0, 1, 2, 5, 6, 15, 16, 17):
    print(f"Block {j:>2}: u = {u[j]:6.1f}, s = {s[j]:4.2f} → rounded {round(s[j])}, width {w[j]}")

stages = sorted(set(w))
depths = [w.count(x) for x in stages]
widths = [round(x / g) * g for x in stages]         # then adjust to multiples of the group width
print("Blocks per stage:", depths)
print("Width per stage:", widths)
Text
Block  0: u =   80.0, s = 0.00 → rounded 0, width 80
Block  1: u =  114.0, s = 0.44 → rounded 0, width 80
Block  2: u =  148.0, s = 0.76 → rounded 1, width 176
Block  5: u =  250.0, s = 1.41 → rounded 1, width 176
Block  6: u =  284.1, s = 1.56 → rounded 2, width 408
Block 15: u =  590.1, s = 2.46 → rounded 2, width 408
Block 16: u =  624.2, s = 2.53 → rounded 3, width 912
Block 17: u =  658.2, s = 2.60 → rounded 3, width 912
Blocks per stage: [2, 4, 10, 2]
Width per stage: [72, 168, 408, 912]

The widths of the 18 blocks climb along the line, and once the exponents are rounded, they split into four segments, giving 2, 4, 10, and 2 blocks per stage, with widths of 72, 168, 408, and 912. This matches RegNetX-1.6GF as listed in the paper, and it also matches the model torchvision builds. The number of blocks per stage doesn't have to be specified separately; the line and the rounding determine it. torchvision's regnet_x_* and regnet_y_*, as well as timm's regnetx_* and regnety_*, are all generated with these formulas, so just pick one by compute.

The authors also went back to check this description. They fit the quantized line to every model from AnyNetXC_C through AnyNetXE_E and computed the fitting error efite_\text{fit}. The scatter plots in the bottom row of Figure 8 show that the best models in each space all have fitting errors near 0, and that from C to E, the models as a whole conform more and more closely to this structure.

RegNet

Since the good models all look like this, the authors simply keep only networks with this structure. A network is then determined by four parameters, dd, w0w_0, waw_a, and wmw_m, plus bb and gg. The sampling ranges are d<64d<64, w0,wa<256w_0,w_a<256, and 1.5≤wm≤31.5\le w_m\le3. The authors call this space RegNet, meaning it contains only regular networks.

The degrees of freedom drop from 16 to 6 and the size of the space shrinks by nearly 10 orders of magnitude, yet the mean error falls from 49.0% to 41.0%, and the best model gets slightly better too. Good models are concentrated enough that randomly sampling about 32 models is likely to turn up a good one.

The authors also confirmed that these conclusions hold beyond the low-compute, short-training setting. With higher compute, longer training, 5-stage networks, or other block types, the three spaces always rank in the same order, RegNetX first, then AnyNetXE_E, then AnyNetXA_A.

Discussion

Where It Breaks with Common Practice

Since good models are concentrated in RegNetX, the authors switch to sampling 100 models at each compute level and training them for 25 epochs, to look at the trend of each parameter:

Six line charts, each with compute (0.2 to 12.8 GFLOPs) on the horizontal axis, a pale all range, a blue good range, and a black best line. d: the best depth stays roughly between 16 and 23, mostly 20; b: the best value is always 1; wm: the best value is roughly between 2.2 and 2.8; g, wa, w0: the best values all grow as compute increases
Figure 11 from the paper, excerpted from page 7 of the v1 PDF. Trends of each RegNetX parameter across compute levels; the blue region is the range that contains the best models with 95% confidence, and the black line is the most likely best value.

Several results go against the habits of the time:

  1. The best depth is very stable. Whatever the compute, the best models have about 20 blocks (about 60 layers). The usual practice is to make the network deeper as compute grows.
  2. No bottleneck needed. The best models have b=1b=1, with the middle layer as wide as the output.
  3. The width multiplier between stages is about 2.5. The common practice is to double the width at each stage.
  4. Inverted bottlenecks and depthwise convolution both do worse. The b<1b<1 common in mobile networks makes results slightly worse, and depthwise convolution with g=1g=1 is worse still. When the authors retested in the appendix at 6.4GF with 100 epochs, the inverted bottleneck fell even further behind.
  5. A fixed resolution of 224×224224\times224 is best. This runs counter to EfficientNet's finding that scaling up the resolution helps, and it holds even at higher compute.

gg, waw_a, and w0w_0, on the other hand, grow with compute. In addition, adding an SE module to the X block gives the RegNetY space, which is better still overall.

The authors also bring in a metric few people usually look at, activations, the total size of the output tensors of all convolutional layers. On a V100 GPU, inference time has a correlation coefficient of 0.897 with activations, but only 0.643 with FLOPs. Hardware like GPUs is often limited by memory bandwidth, so the size of the intermediate results predicts speed better than the number of multiply-adds does. Among the best models, activations grow roughly with the square root of compute, while parameters grow linearly.

Based on these trends, the authors further constrain RegNetX with b=1b=1, d≤40d\le40, and wm≥2w_m\ge2, and limit parameters and activations, giving a faster, more memory-efficient space; all the comparisons that follow use this version.

Compared with ResNet and ResNeXt

To compare final models, the authors try 25 random parameter settings at each compute level, pick the best, and train it 5 times for 100 epochs. All models, including the ResNets and ResNeXts being compared, use the same basic training setup, with no regularization or training tricks beyond weight decay:

Table: Excerpted from Table 3(b) of the paper, grouped by similar compute. Inference time is for one batch of 64 images on a V100.
ModelGFLOPsParametersInference (ms)Top-1 error
ResNet-504.122.6M5323.2%
ResNeXt-504.225.0M7821.9%
RegNetX-4.0GF4.022.1M6921.4%
ResNet-1017.844.6M9021.4%
ResNeXt-1018.044.2M13720.7%
RegNetX-8.0GF8.039.6M9420.7%
ResNet-15211.560.2M13020.9%
ResNeXt-15211.760.0M19720.4%
RegNetX-12GF12.146.1M13720.3%

In all three groups, RegNetX is the best or tied for the best. In the 8GF group, RegNetX ties ResNeXt-101 but needs only 94 ms for inference, versus 137 ms for ResNeXt-101. These networks use the same components and training setup and differ only in structure, so the authors conclude that all of these gains come from the design space.

The Mobile Regime

Around 600MF, RegNetX-600MF has a top-1 error of 25.9% and RegNetY-600MF 24.5%. At the same compute, MobileNet-V2 reports 25.3% and ShuffleNet V2 25.1%, while the NAS-found NASNet-A gets 26.0% and AmoebaNet-C 24.3%.

The competitors' numbers are those reported in their own papers, usually with longer training and assorted enhancement tricks; RegNet uses only the basic 100-epoch setup and still comes quite close. The authors hope these simple models can serve as baselines for future research.

Compared with EfficientNet

Last comes EfficientNet, the strongest model of the time. The authors take EfficientNet's original architectures but retrain them with the same training setup as RegNet, tuning only the learning rate and weight decay separately for them:

ModelGFLOPsParametersActivationsTop-1 error
EfficientNet-B00.45.3M6.7M24.9%
RegNetY-400MF0.44.3M3.9M25.9%
EfficientNet-B31.812.0M23.8M22.5%
RegNetY-1.6GF1.611.2M8.0M22.0%
EfficientNet-B59.930.0M98.9M21.5%
RegNetY-8.0GF8.039.2M18.0M20.1%
Table: Three groups excerpted from Table 4 of the paper. Both use the basic 100-epoch training setup with weight decay only; inference time is measured as in the previous table.
ModelInference (ms)Training (hours)
EfficientNet-B03411.7
RegNetY-400MF195.1
EfficientNet-B311432.1
RegNetY-1.6GF3910.1
EfficientNet-B5504135.1
RegNetY-8.0GF11328.1

At very low compute, EfficientNet is better; as compute goes up, RegNetY takes the lead. The speed gap is even more striking. EfficientNet-B5 takes 504 ms per inference batch, while RegNetY-8.0GF needs only 113 ms (by the time B5 finishes one batch, it has already run through four), with lower error to boot.

The speed gap ties back to activations. EfficientNet scales up both resolution and depth, so its activations grow roughly linearly with compute, reaching 98.9M for B5; RegNet's grow with the square root, only 18.0M at 8.0GF.

Keep the training setup in mind when reading this table. The original EfficientNet paper used longer training and enhancements such as AutoAugment, and reported much lower errors, 16.7% for B5, for example. The authors' own experiments also show that the training setup alone can shift EfficientNet-B0's error by about 2 percentage points. So this table compares “which architecture is better under the same training conditions,” not the best results each can achieve.

Conclusion

Do good architectures all look alike? Within this paper's design space, at least, the answer is yes. Narrowing all the way down from 101810^{18} networks, the good models that remain all have widths on the same quantized line, a depth of about 20 blocks, no bottleneck, and widths that grow by a factor of about 2.5 from one stage to the next.

These regularities were found with a fixed X block, low compute, and short training, and the authors acknowledge that putting more options, such as operators, into the design space might lead to different answers.

To draw this line, the authors trained several thousand models just to compare design spaces. That's not cheap, but what they got in return is a set of rules you can actually explain, far easier to make sense of than a NAS-delivered network that amounts to “that's just how it is, don't ask.”