For almost 70 years, researchers have typically selected the width of neural networks' layers either manually or through automated hyperparameter tuning methods such as grid search and, more recently, neural architecture search. This paper challenges the status quo by introducing an easy-to-use technique to learn an unbounded width of a neural network's layer during training. The method jointly optimizes the width and the parameters of each layer via standard backpropagation. We apply the technique to a broad range of data domains such as tables, images, text, sequences, and graphs, showing how the width adapts to the task's difficulty. A by product of our width learning approach is the easy truncation of the trained network at virtually zero cost, achieving a smooth trade-off between performance and compute resources. Alternatively, one can dynamically compress the network until performances do not degrade. In light of recent foundation models trained on large datasets, requiring billions of parameters and where hyper-parameter tuning is unfeasible due to huge training costs, our approach introduces a viable alternative for width learning.
Figures & tables
Figure 1: (Left) The graphical model of AWN , with dark observable random variables and white latent ones. (Middle) The distribution fℓ over hidden units’ importance at layer ℓ is parametrized by λℓ . The width of layer ℓ is chosen as the quantile function of the distribution fℓ evaluated at k and denoted by Dℓ . (Right) The hidden units’ activations at layer ℓ are rescaled by their importance.
Fixed
AWN
Width (Fixed)
Width ( AWN )
Mean
(Std)
Mean
(Std)
Mean
(Std)
DoubleMoon
100.0
(0.0)
100.0
(0.0)
8
8.1
(2.8)
Spiral
99.5
(0.5)
99.8
(0.1)
16
65.9
(8.7)
SpiralHard
98.0
(2.0)
100.0
(0.0)
32
227.4
(32.4)
pol
99.3
(0.2)
99.2
(0.1)
48
84
(11.0)
MiniBooNE
92.9
(0.3)
93.2
(0.1)
32
53
(11.1)
Table 1: Performances and total width of MLP layers for the fixed and AWN versions of the various models used. The exact width chosen by model selection on the graph datasets is unknown since we report published results. “Linear" means the chosen downstream classifier is a linear model.
Figure 2: (Left) The learned width adapts to the increasing difficulty of the task, from the DoubleMoon to SpiralHard. (Right) AWN reaches perfect test accuracy with a comparable amount of epochs on DoubleMoon and Spiral, while it converges faster on SpiralHard.
Figure 3: Training converges to similar widths on SpiralHard for different batch sizes (left) and starting rates ν , but the latter seems to require a bounded nonlinearity such as ReLU6 to converge in a reasonable amount of epochs (right).
Figure 4: It is possible to regularize the width at training time by increasing the magnitude of the loss term logq(ν)p(ν) . The total width is reduced by more than 50% (left) while preserving accuracy (right). The inset plot refers to the loss term that AWN tries to maximize.
Figure 5: (Left) Thanks to the soft ordering imposed on the neurons, one can also truncate the neural network after training by simply removing the last neurons. (Right) The distribution of neurons’ activations for all Spiral test samples follows an exponential-like curve.
fℓ(j;νℓ)
Mean Accuracy
Max Accuracy
Mean Total Width
Exponential
80.27 (19.9)
100.00
954.4 (1083.9)
Power Law
81.82 (16.6)
100.00
2952.4 (3371.6)
Sigmoidal
76.85 (18.3)
100.00
426.8 (268.4)
Table 2: Analysis of the impact of different families of importance functions on SpiralHard validation performance and learned width, averaged across different hyper-parameter configurations.
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 6: On the left, we provide a visualization of the exponential density with λ=0.5 , its cumulative density, and the quantile function evaluated at k=0.9 , which returns a value close to 5 . On the right, we show the discretized exponential and its cumulative mass function; we can see that the quantile function of the continuous density provides an upper bound for the natural where the cumulative mass function is greater than k=0.9 . Therefore, one can safety use the ceiling of the output of the quantile function to determine the width Dℓ to use for a given value of λ .
Figure 7: (Left) Effect of the rescaled initialization scheme (“Kaiming+”) on a ReLU-based MLP, where neurons’ activations are computed using Equation 10 . Compared to the standard initialization, the variance of activations agrees with the theoretical result. (Right) Without the rescaled initialization, convergence is hard to attain on the SpiralHard dataset (please refer to the next section for details about the dataset).
Figure 8: The DoubleMoon, Spiral, and SpiralHard synthetic datasets are used to test AWN ’s inner workings, and are ordered difficulty. Orange and blue colors denote different classes.
# Samples
# Features
# Classes
Outer Split (TR/VL/TE)
Inner Split (TR/VL)
DoubleMoon
5000
2
2
3600/400/1000
3600/400
Spiral
5000
2
2
3600/400/1000
3600/400
SpiralHard
10000
2
2
7200/800/2000
7200/800
pol
15000
48
2
10800/1200/3000
10800/1200
MiniBooNE
130064
50
2
93645/10406/26013
93645/10406
credit card clients
30000
23
2
21600/2400/6000
21600/2400
Appendix
Table 3: Dataset statistics and number of samples in each split are shown.
Multiply learning rate by 0.1 at epochs 50,100,150
AWN Specific
Appendix
Table 5: Hyper-parameter configurations for standard MLP and AWN versions on image classification datasets.
Hyper-Parameter
NCI1 / REDDIT-B
Batch Size
[32,128]
Epochs
1000
Graph Conv. Layers
[1,2,4]
Global Pooling
[sum, mean]
Optimizer
Adam, learning rate 0.01
AWN Specific
Appendix
Table 6: Hyper-parameter configurations for AWN versions on graph classification datasets.
Spiral
SpiralHard
REDDIT-B
Fixed
99.5(0.5)
98.0(2.0)
87.0(4.4)
AWN
99.8(0.1)
100.0(0.0)
90.2(1.3)
Fixed+
100.0(0.1)
83.2(17.0)
90.7(1.4)
Appendix
Table 15
# Total Width
Mean
Std
50
89.28
3.50
250
92.89
1.45
500
92.67
2.03
793
92.83
3.55
1000
93.06
1.60
1250
92.78
2.33
Appendix
Table 7: We report REDDIT-B validation performances, averaged across the 10 outer folds, for a fixed-width DGN. The other hyper-parameters match those selected by AWN during model selection, as per this specific experiment.
Figure 9: We present an analysis similar to Figure 2 but for image classification datasets of increasing difficulty. One can observe the jumps caused by the learning rate’s scheduling strategy.
Grid Search
Random Search
Local Search
Bayes. Optim.
AWN
MNIST
99.6(0.1)
99.6(0.0)
99.5
99.4
99.7(0.0)
CIFAR10
91.4(0.2)
90.1(0.5)
90.6
91.2
91.4(0.2)
CIFAR100
66.5(0.4)
64.9(1.1)
64.9
65.9
63.1(4.0)
Appendix
Table 8: Comparison between different NAS approaches and AWN . We remind the reader that NAS is an orthogonal and complementary research direction to AWN .
Figure 10: Impact of different batch sizes and starting exponential rates λ , organized by type of non-linear activation function.
Figure 11: Learned neurons per layer (from 1 to 5), averaged over 10 final runs for each of the 10 best configurations selected in the outer folds. The first and second rows refer to NCI1, the third and fourth refer to REDDIT-B. One can observe similar trends in most cases.
Figure 12: We report learned width and validation accuracy trends averaged over 1-layer AWN configurations on SpiralHard. We see how a higher quantile k (i.e., a better ELBO approximation) grants more stable performances. All architectures keep adapting to the task.
AWN
AWN - NoReg
Width ( AWN )
Width ( AWN - NoReg)
Mean
(Std)
Mean
(Std)
Mean
(Std)
Mean
(Std)
DoubleMoon
100.0
(0.0)
100.0
(0.2)
8
(2.8)
17
(16.6)
Spiral
99.8
(0.1)
100.0
(0.0)
66
(8.7)
108
(26.8)
SpiralHard
100.0
(0.0)
100.0
(0.0)
227
(32.4)
539
(809.8)
pol
99.2
(0.1)
99.2
(0.1)
84
(11.0)
2335
(552.8)
MiniBooNE
93.2
(0.1)
93.8
(0.2)
53
(11.1)
4907
(1141)
Appendix
Table 9: We compare performances and learned width of AWN , where we removed regularization and bounded activations from hyper-parameters, with the results in the main paper.
Dataset
Avg Fixed (s)
Avg AWN (s)
Single-Run Ratio ( ↓ )
Model Selection Ratio ( ↓ )
DoubleMoon
70
218
3.1 ×
0.62 ×
Spiral
120
141
1.1 ×
0.24 ×
SpiralHard
1982
7772
3.9 ×
0.78 ×
pol
1251
1088
0.87 ×
0.17 ×
MiniBooNE
11794
4496
0.38 ×
0.07 ×
creditcards
2104
1815
0.90 ×
0.14 ×
Appendix
Table 10: We report average wall-clock times for AWN and the fixed model, measured either over model selection configurations or final runs when no selection is performed. We also provide two ratios: i) single-run wall-clock times and ii) total model selection time (fixed models always test at least five widths).
Figure 13: We show the impact of removing the most important neurons, either in batch (top) or individually (bottom) on Spiral performances, using the same experiment as Figure 5 .