Module-wise Training of Neural Networks via the Minimizing Movement
  Scheme
Greedy layer-wise or module-wise training of neural networks is compelling in
constrained and on-device settings where memory is limited, as it circumvents a
number of problems of end-to-end back-propagation. However, it suffers from a
stagnation problem, whereby early layers overfit and deeper layers stop
increasing the test accuracy after a certain depth. We propose to solve this
issue by introducing a module-wise regularization inspired by the minimizing
movement scheme for gradient flows in distribution space. We call the method
TRGL for Transport Regularized Greedy Learning and study it theoretically,
proving that it leads to greedy modules that are regular and that progressively
solve the task. Experimentally, we show improved accuracy of module-wise
training of various architectures such as ResNets, Transformers and VGG, when
our regularization is added, superior to that of other module-wise training
methods and often to end-to-end training, with as much as 60% less memory
usage.
Skander Karkar, Ibrahim Ayed, Emmanuel de Bézenac, Patrick Gallinari
# Module-wise Training of Neural Networks via the Minimizing Movement Scheme

###### Abstract

Greedy layer-wise or module-wise training of neural networks is compelling in constrained and on-device settings where memory is limited, as it circumvents a number of problems of end-to-end back-propagation. However, it suffers from a stagnation problem, whereby early layers overfit and deeper layers stop increasing the test accuracy after a certain depth. We propose to solve this issue by introducing a module-wise regularization inspired by the minimizing movement scheme for gradient flows in distribution space. We call the method TRGL for Transport Regularized Greedy Learning and study it theoretically, proving that it leads to greedy modules that are regular and that progressively solve the task. Experimentally, we show improved accuracy of module-wise training of various architectures such as ResNets, Transformers and VGG, when our regularization is added, superior to that of other module-wise training methods and often to end-to-end training, with as much as \(60\%\) less memory usage.

## 1 Introduction

End-to-end backpropagation is the standard training method of neural networks. However, it requires storing the whole model and computational graph during training, which requires large memory consumption. It also prohibits training the layers in parallel. Dividing the network into modules, a module being made up of one or more layers, accompanied by auxiliary classifiers, and greedily solving module-wise optimization problems sequentially (i.e. one after the other fully) or in parallel (i.e. at the same time batch-wise), consumes much less memory than end-to-end training as it does not need to store as many activations at the same time, and when done sequentially, only requires loading and training one module (so possibly one layer) at a time. Module-wise training has therefore been used in constrained settings in which end-to-end training can be impossible such as training on mobile devices [58; 57] and dealing with very large whole slide images [65]. When combined with batch buffers, parallel module-wise training also allows for parallel training of the modules [8]. Despite its simplicity, module-wise training has been recently shown to scale well [8; 47; 60; 45], outperforming more complicated alternatives to end-to-end training such as synthetic [33; 14] and delayed [32; 31] gradients, while having superior memory savings.

In a classification task, module-wise training splits the network into successive modules, a module being made up of one or more layers. Each module takes as input the output of the previous module, and each module has an auxiliary classifier so that a local loss can be computed, with backpropagation happening only inside the modules and not between them (see Figure 1 below).

The main drawback of module-wise training is the well-documented _stagnation problem_ observed in [43; 7; 60; 47], whereby early modules overfit and learn more discriminative features than end-to-end
training, destroying task-relevant information, and deeper modules don't improve the test accuracy significantly, or even degrade it, which limits the deployment of module-wise training. We further highlight this phenomenon in Figures 2 and 3 in Section 4.5. To tackle this issue, InfoPro [60] propose to maximize the mutual information that each module keeps with the input, in addition to minimizing the loss. [7] make the auxiliary classifier deeper and Sedona [47] make the first module deeper. These last two methods lack a theoretical grounding, while InfoPro requires a second auxiliary network for each module besides the classifier. We propose a different perspective, leveraging the analogy between residual connections and the Euler scheme for ODEs [61]. To preserve input information, we minimize the kinetic energy of the modules along with the training loss. Intuitively, this forces the modules to change their input as little as possible. We leverage connections with the theories of gradient flows in distribution space and optimal transport to analyze our method theoretically.

Our approach is particularly well-adapted to networks that use residual connections such as ResNets [27; 28], their variants (e.g. ResNeXt [62], Wide ResNet [63], EfficientNet [56] and MobileNetV2 [48]) and vision transformers that are made up essentially of residual connections [39; 17], but is immediately usable on any network where many layers have the same input and output dimension such as VGG [52]. Our contributions are the following:

* We propose a new method for module-wise training. Being a regularization, it is lighter than many recent state-of-the-art methods (PredSim [45], InfoPro [60]) that train another auxiliary network besides the auxiliary classifier for each module.
* We theoretically justify our method, proving that it is a transport regularization that forces the module to be an optimal transport map making it more regular and stable. We also show that it amounts to a discretization of the gradient flow of the loss in probability space, which means that the modules progressively minimize the loss and explains why the method avoids the accuracy collapse observed in module-wise training.
* Experimentally, we consistently improve the test accuracy of module-wise trained networks (ResNets, VGG and Swin-Transformer) beating 8 other methods, in sequential and parallel module-wise training, and also in _multi-lap sequential_ training, a variant of sequential module-wise training that we introduce and that performs better in many cases. In particular, our regularization makes parallel module-wise training superior or comparable in accuracy to end-to-end training, while consuming \(10\%\) to \(60\%\) less memory.

## 2 Transport-regularized module-wise training

The typical setting of (sequential) module-wise training for minimizing a loss \(L\), is, given a dataset \(\mathcal{D}\), to solve one after the other, for \(1{\leq}k{\leq}K\), Problems

\[(T_{k},F_{k})\in\arg\min_{T,F}\sum_{x\in\mathcal{D}}L(F,T\circ G_{k-1}(x)) \tag{1}\]

Figure 1: Module-wise training.
where \(G_{k}=T_{k}\circ\ldots\circ T_{1}\) for \(1{\leq}k{\leq}K\), \(G_{0}{=}\texttt{id}\), \(T_{k}\) is the module (one or many layers) and \(F_{k}\) is an auxiliary classifier. Module \(T_{k}\) receives the output of module \(T_{k-1}\), and auxiliary classifier \(F_{k}\) computes the prediction from the output of \(T_{k}\) so the loss can be computed. The inputs are \(x\) and \(L\) has access to their labels \(y\) to calculate the loss. i.e. \(L(F,T\circ G_{k-1}(x))=l(F\circ T\circ G_{k-1}(x),y)\) where \(l\) is a machine learning loss such as cross-entropy. See Figure 1. The final network trained this way is \(F_{K}\circ G_{K}\). But, at inference, we can stop at any depth \(k\) and use \(F_{k}\circ G_{k}\) if it performs better. Indeed, an intermediate module often performs as well or better than the last module because of the early overfitting and subsequent stagnation or collapse problem of module-wise training [43; 7; 60; 47].

We propose below in (2) a regularization that avoids the destruction of task-relevant information by the early modules by forcing them to minimally modify their input. Proposition 2.2 proves that by using our regularization (2), we are indeed making the modules build upon each other to solve the task, which is the property we desire in module-wise training, as the modules now act as successive proximal optimization steps in the _minimizing movement scheme_ optimization algorithm for maximizing the separability of the data representation. The background on optimal transport (OT), gradient flows and the minimizing movement scheme is in Appendices A and B.

### Method statement

To keep greedily-trained modules from overfitting and destroying information needed later, we penalize their kinetic energy to force them to preserve the geometry of the problem as much as possible. If each module is a single residual block (that is a function \(T{=}\texttt{id}{+}r\), which includes many transformer architectures [39; 17]), its kinetic energy is simply the squared norm of its residue \(r{=}T{-}\texttt{id}\), which we add to the loss \(L\) in the target of the greedy problems (1). All layers that have the same input and output dimension can be rewritten as residual blocks and the analysis applies to a large variety of architectures such as VGG [52]. Given \(\tau{>}0\), we now solve, for \(1{\leq}k{\leq}K\), Problems

\[(T_{k}^{\tau},F_{k}^{\tau})\in\arg\min_{T,F}\sum_{x\in\mathcal{D}}L(F,T\circ G _{k-1}^{\tau}(x))+\frac{1}{2\tau}\|T\circ G_{k-1}^{\tau}(x){-}G_{k-1}^{\tau}(x )\|^{2} \tag{2}\]

where \(G_{k}^{\tau}{=}T_{k}^{\tau}\circ\ldots\circ T_{1}^{\tau}\) for \(1{\leq}k{\leq}K\) and \(G_{0}^{\tau}{=}\texttt{id}\). The final network is \(F_{k}^{\tau}{\circ}G_{K}^{\tau}\). Intuitively, this biases the modules towards moving the points as little as possible, thus at least keeping the performance of the previous module. Residual connections are already biased towards small displacements and this bias is desirable and should be encouraged [35; 64; 26; 15; 36]. But the method can be applied to any module where \(T(x)\) and \(x\) have the same dimension so that \(T(x){-}x\) can be computed.

To facilitate the theoretical analysis, we rewrite the method in a more general formulation using data distribution \(\rho\), which can be discrete or continuous, and the distribution-wide loss \(\mathcal{L}\) that arises from the point-wise loss \(L\). Then Problem (2) is equivalent to Problem

\[(T_{k}^{\tau},F_{k}^{\tau})\in\arg\min_{T,F}\ \mathcal{L}(F,T_{\sharp}\rho_{k}^ {\tau})+\frac{1}{2\tau}\int_{\Omega}\|T(x)-x\|^{2}\,\mathrm{d}\rho_{k}^{\tau}(x) \tag{3}\]

with \(\rho_{k+1}^{\tau}{=}(T_{k}^{\tau})_{\sharp}\rho_{k}^{\tau}\), \(\rho_{1}^{\tau}{=}\rho\) and \(\mathcal{L}(F,T_{\sharp}\rho_{k}^{\tau})=\int L(F,T(x))\,\mathrm{d}\rho_{k}^{ \tau}(x)=\int L(F,z)\,\mathrm{d}T_{\sharp}\rho_{k}^{\tau}(x)\).

### Link with the minimizing movement scheme

We now formulate our main result: solving Problems (3) is equivalent to following a _minimizing movement scheme (MMS)_[50] in distribution space for minimizing \(\mathcal{Z}(\mu):=\min_{F}\mathcal{L}(F,\mu)\), which is the loss of the best classifier. If we are limited to linear classifiers, \(\mathcal{Z}(\rho_{k}^{\tau})\) represents the linear separability of the representation \(\rho_{k}^{\tau}\) at module \(k\) of the data distribution \(\rho\). The MMS, introduced in [24; 23], is a metric counterpart to Euclidean gradient descent for minimizing functionals over distributions. In our case, \(\mathcal{Z}\) is the functional we want to minimize. We define the MMS below in Definition 2.1

The distribution space we work in is the metric Wasserstein space \(\mathbb{W}_{2}(\Omega)=(\mathcal{P}(\Omega),W_{2})\), where \(\Omega\subset\mathbb{R}^{d}\) is a convex compact set, \(\mathcal{P}(\Omega)\) is the set of probability distributions over \(\Omega\) and \(W_{2}\) is the Wasserstein distance over \(\mathcal{P}(\Omega)\) derived from the optimal transport problem with Euclidean cost:

\[W_{2}^{2}(\alpha,\beta)=\min_{T\,\mathrm{s.t.}\ T_{\sharp}\alpha=\beta}\int_{ \Omega}\|T(x)-x\|^{2}\,\mathrm{d}\alpha(x) \tag{4}\]

where we assume that \(\partial\Omega\) is negligible and that the distributions are absolutely continous.
**Definition 2.1**.: Given \(\mathcal{Z}:\mathbb{W}_{2}(\Omega)\rightarrow\mathbb{R}\), and starting from \(\rho_{1}^{\tau}\in\mathcal{P}(\Omega)\), the Minimizing Movement Scheme (MMS) takes proximal steps for minimizing \(\mathcal{Z}\). It is s given by

\[\rho_{k+1}^{\tau}\in\arg\min_{\rho\in\mathcal{P}(\Omega)}\ \mathcal{Z}(\rho)+ \frac{1}{2\tau}W_{2}^{2}(\rho,\rho_{k}^{\tau}) \tag{5}\]

The MMS (5) can be seen as a non-Euclidean implicit Euler step for following the gradient flow of \(\mathcal{Z}\), and \(\rho_{k}^{\tau}\) converges to a minimizer of \(\mathcal{Z}\) under some conditions (see the end of this section).

So under the mentioned assumptions on \(\Omega\) and absolute continuity of the distributions, we have that Problems (3) are equivalent to the minimizing movement scheme (5):

**Proposition 2.2**.: _The distributions \(\rho_{k+1}^{\tau}=(T_{k}^{\tau})_{\sharp}\rho_{k}^{\tau}\), where the functions \(T_{k}^{\tau}\) are found by solving (3) and \(\rho_{1}^{\tau}=\rho\) is the data distribution, coincide with the MMS (5) for \(\mathcal{Z}=\min_{F}\mathcal{L}(F,.)\)._

Proof.: The minimizing movement scheme (5) is equivalent to taking \(\rho_{k+1}^{\tau}=(T_{k}^{\tau})_{\sharp}\rho_{k}^{\tau}\) where

\[T_{k}^{\tau}\in\arg\min_{T:\Omega\rightarrow\Omega}\mathcal{Z}(T_{\sharp}\rho _{k}^{\tau})+\frac{1}{2\tau}W_{2}^{2}(T_{\sharp}\rho_{k}^{\tau},\rho_{k}^{ \tau}) \tag{6}\]

under conditions that guarantee the existence of a transport map between \(\rho_{k}^{\tau}\) and any other measure, and absolute continuity of \(\rho_{k}^{\tau}\) suffices, and the loss can ensure that \(\rho_{k+1}^{\tau}\) is also absolutely continuous. Among the functions \(T_{k}^{\tau}\) that solve problem (6), is the optimal transport map from \(\rho_{k}^{\tau}\) to \(\rho_{k+1}^{\tau}\). To solve specifically for this optimal transport map, we have to solve the equivalent Problem

\[T_{k}^{\tau}\in\arg\min_{T}\mathcal{Z}(T_{\sharp}\rho_{k}^{\tau})+\frac{1}{2 \tau}\int_{\Omega}\|T(x)-x\|^{2}\,\mathrm{d}\rho_{k}^{\tau}(x) \tag{7}\]

Problems (6) and (7) have the same minimum value, but the minimizer of (7) is now an optimal transport map between \(\rho_{k}^{\tau}\) and \(\rho_{k+1}^{\tau}\). This is immediate from the definition (4) of the \(W_{2}\) distance. Equivalently minimizing first over \(F\) and then over \(T\) in (3), it follows from the definition of \(\mathcal{Z}\) that Problems (3) and (7) are equivalent, which concludes. 

Since we solve Problems (3) over neural networks, their representation power shown by universal approximation theorems [13; 29] is important to get close to equivalence between (5) and (3), as we need to approximate an optimal transport map. We also know that the training of each module, if it is shallow, converges [5; 6; 34; 22; 18].

If \(\mathcal{Z}\) is lower-semi continuous then Problems (5) always admit a solution because \(\mathcal{P}(\Omega)\) is compact. If \(\mathcal{Z}\) is also \(\lambda\)-geodesically convex for \(\lambda{>}0\), we have convergence of \(\rho_{k}^{\tau}\) as \(k{\rightarrow}\infty\) and \(\tau{\rightarrow}0\) to a minimizer of \(\mathcal{Z}\), potentially under more technical conditions (see Appendix B). Even though a machine learning loss will usually not satisfy these conditions, this analysis offers hints as to why our method avoids in practice the problem of stagnation or collapse in performance of module-wise training as \(k\) increases, as we are making proximal local steps in Wasserstein space to minimize the loss. This convergence discussion also suggests taking \(\tau\) as small as possible and many modules.

### Regularity result

As a secondary result, we show that Problem (3) has a solution and that the solution module \(T_{k}^{\tau}\) is an optimal transport map between its input and output distributions, which means that it comes with some regularity. [36] show that these networks generalize better and overfit less in practice. We assume that the minimization in \(F\) is over a compact set \(\mathcal{F}\), that \(\rho_{k}^{\tau}\) is absolutely continuous, that \(\mathcal{L}\) is continuous and non-negative, that \(\Omega\) is convex and compact and that \(\partial\Omega\) is negligible.

**Proposition 2.3**.: _Problem (3) has a minimizer \((T_{k}^{\tau},F_{k}^{\tau})\) such that \(T_{k}^{\tau}\) is an optimal transport map. And for any minimizer \((T_{k}^{\tau},F_{k}^{\tau})\), \(T_{k}^{\tau}\) is an optimal transport map._

The proof is in Appendix C. OT maps have regularity properties under some boundedness assumptions. Given Theorem A.1 in Appendix A taken from [20], \(T_{k}^{\tau}\) is \(\eta\)-Holder continuous almost everywhere and if the optimization algorithm we use to solve the discretized problem (2) returns an approximate solution pair \((\tilde{F}_{k}^{\tau},\tilde{T}_{k}^{\tau})\) such that \(\tilde{T}_{k}^{\tau}\) is an \(\epsilon\)-optimal transport map, i.e. \(\|\tilde{T}_{k}^{\tau}-T_{k}^{\tau}\|_{\infty}\leq\epsilon\), then we have (using the triangle inequality) the following stability property of the module \(\tilde{T}_{k}^{\tau}\):

\[\|\tilde{T}_{k}^{\tau}(x)-\tilde{T}_{k}^{\tau}(y)\|\leq 2\epsilon+C\|x-y\|^{\eta} \tag{8}\]
for almost every \(x,y\in\text{supp}(\rho_{k}^{\tau})\) and \(C{>}0\). Composing these stability bounds on \(T_{k}^{\tau}\) and \(\tilde{T}_{k}^{\tau}\) allows to get bounds for the composition networks \(G_{k}^{\tau}\) and \(\tilde{G}_{k}^{\tau}{=}\tilde{T}_{k}^{\tau}\circ...\circ\tilde{T}_{1}^{\tau}\).

To summarize Section 2, the transport regularization makes each module more regular and it allows the modules to build on each other as \(k\) increases to solve the task, which is the property we desire.

## 3 Practical implementation

### Multi-block modules

For simplicity, we presented in (2) the case where each module is a single residual block. However, in practice, we often split the network into modules that are made-up of many residual blocks each. We show here that regularizing the kinetic energy of such modules still amounts to a transport regularization, which means that the theoretical results in Propositions 2.2 and 2.3 still apply.

If each module \(T_{k}\) is made up of \(M\) residual blocks, i.e. applies \(x_{m+1}{=}x_{m}{+}r_{m}(x_{m})\) for \(0{\leq}m{<}M\), then its total discrete kinetic energy for a single data point \(x_{0}\) is the sum of its squared residue norms \(\sum\|r_{m}(x_{m})\|^{2}\), since a residual network can be seen as a discrete Euler scheme for an ordinary differential equation [61] with velocity field \(r\):

\[x_{m+1}=x_{m}+r_{m}(x_{m})\ \longleftrightarrow\ \partial_{t}x_{t}=r_{t}(x_{t}) \tag{9}\]

and \(\sum\|r_{m}(x_{m})\|^{2}\) is then the discretization of the total kinetic energy \(\int_{0}^{1}\|r_{t}(x)\|^{2}\,\mathrm{d}t\) of the ODE. If \(\psi_{m}^{x}\) denotes the position of a point \(x\) after \(m\) residual blocks, then regularizing the kinetic energy of multi-block modules now means solving

\[(T_{k}^{\tau},F_{k}^{\tau})\in\arg\min_{T,F}\sum_{x\in\mathcal{D }}(L(F,T(G_{k-1}^{\tau}(x))+\frac{1}{2\tau}\sum_{m=0}^{M-1}\|r_{m}(\psi_{m}^{x })\|^{2}) \tag{10}\] \[\text{s.t. }T=(\mathtt{id}+r_{M-1})\circ...\circ(\mathtt{id}+r_{0 }),\ \psi_{0}^{x}=G_{k-1}^{\tau}(x),\psi_{m+1}^{x}=\psi_{m}^{x}+r_{m}(\psi_{m}^{x})\]

where \(G_{k}^{\tau}{=}T_{k}^{\tau}\circ...\circ T_{1}^{\tau}\) for \(1{\leq}k{\leq}K\) and \(G_{0}^{\tau}{=}\mathtt{id}\). We also minimize this sum of squared residue norms instead of \(\|T(x)-x\|^{2}\) (the two no longer coincide) as it works better in practice, which we assume is because it offers a more localized control of the transport. As expressed in (9), a residual network can be seen as an Euler scheme of an ODE and Problem (10) is then the discretization of

\[(T_{k}^{\tau},F_{k}^{\tau})\in\arg\min_{T,F}\ \mathcal{L}(F,T_{ \sharp}\rho_{k}^{\tau})+\frac{1}{2\tau}\int_{0}^{1}\|v_{t}\|_{L^{2}((\phi_{t}) \sharp\rho_{k}^{\tau})}^{2}\,\mathrm{d}t \tag{11}\] \[\text{s.t. }T=\phi_{1},\ \partial_{t}\phi_{t}^{x}=v_{t}(\phi_{t}^{x }),\ \phi_{0}^{\cdot}=\mathtt{id}\]

where \(\rho_{k+1}^{\tau}=(T_{k}^{\tau})_{\sharp}\rho_{k}^{\tau}\) and \(r_{m}\) is the discretization of vector field \(v_{t}\) at time \(t=m/M\). Here, distributions \(\rho_{k}^{\tau}\) are pushed forward through the maps \(T_{k}^{\tau}\) which correspond to the flow \(\phi\) at time \(t=1\) of the kinetically-regularized velocity field \(v_{t}\). We recognize in the second term in the target of (11) the optimal transport problem in its dynamic formulation (15) from [9], and given the equivalence between the Monge OT problem (4) and the dynamic OT problem (15) in Appendix A, Problem (11) is in fact equivalent to the original continuous formulation (3), and the theoretical results in Section 2 follow immediately (see also the proof of Proposition 2.3 in Appendix C).

### Solving the module-wise problems

The module-wise problems can be solved in two ways. One can completely train each module with its auxiliary classifier for \(N\) epochs before training the next module, which receives as input the output of the previous trained module. We call this _sequential_ module-wise training. But we can also do this batch-wise, i.e. do a complete forward pass on each batch but without a full backward pass, rather a backward pass that only updates the current module \(T_{k}^{\tau}\) and its auxiliary classifier \(F_{k}^{\tau}\), meaning that \(T_{k}^{\tau}\) forwards its output to \(T_{k+1}^{\tau}\) immediately after it computes it. We call this _parallel_ module-wise training. It is called _decoupled_ greedy training in [8], which shows that combining it with batch buffers solves all three locking problems and allows a linear training parallelization in the depth of the network. We propose a variant of sequential module-wise training that we call _multi-lap sequential_ module-wise training, in which instead of training each module for \(N\) epochs, we train each module from the first to the last sequentially for \(N/R\) epochs, then go back and train from the first module to
the last for \(N/R\) epochs again, and we do this for \(R\) laps. For the same total number of epochs and training time, and the same advantages (loading and training one module at a time) this provides a non-negligible improvement in accuracy over normal sequential module-wise training in most cases, as shown in Section 4. Despite our theoretical framework being that of sequential module-wise training, our method improves the test accuracy of all three module-wise training regimes.

### Varying the regularization weight

The discussion in Section 2.2 suggests taking a fixed weight \(\tau\) for the transport cost that is as small as possible. However, instead of using a fixed \(\tau\), we might want to vary it along the depth \(k\) to further constrain with a smaller \(\tau_{k}\) the earlier modules to avoid that they overfit or the later modules to maintain the accuracy of earlier modules. We might also want to regularize the network further in earlier epochs when the data is more entangled. We propose in Appendix D to formalize this varying weight \(\tau_{k,i}\) across modules \(k\) and SGD iterations \(i\) by using a scheme inspired by the method of multipliers to solve Problems (2) and (10). However, it works best in only one experiment in practice. The observed dynamics of \(\tau_{k,i}\) suggest simply finding a fixed value of \(\tau\) that is multiplied by 2 for the second half of the network, which works best in all the other experiments (see Appendix E).

## 4 Experiments

We call our method TRGL for Transport-Regularized Greedy Learning. For the auxiliary classifiers, we use the architecture from DGL [7; 8], that is a convolution followed by an average pooling and a fully connected layer, which is very similar to that used by InfoPro [60], except for the Swin Transformer where we use a linear layer. We call vanilla greedy module-wise training with the same architecture but without our regularization VanGL, and we include its results in all tables for ablation study purposes. The code is available at github.com/block-wise/module-wise and implementation details are in Appendix E.

### Parallel module-wise training

To compare with other methods, we focus first on parallel training, as it performs better than sequential training and has been more explored recently. The first experiment is training in parallel 3 residual architectures and a VGG-19 [52] divided into 4 modules of equal depth on TinyImageNet. We compare in Table 1 our results in this setup to three of the best recent parallel module-wise training methods: DGL [8], PredSim [45] and Sedona [47], from Table 2 in [47]. We find that our TRGL has a much better test accuracy than the three other methods, especially on the smaller architectures. It also performs better than end-to-end training on the three ResNets. Parallel TRGL in this case with 4 modules consumes \(10\) to \(21\%\) less memory than end-to-end training (with a batch size of 256).

The second experiment is training in parallel two ResNets divided into 2 modules on CIFAR100 [37]. We compare in Table 2 our results in this setup to the two delayed gradient methods DDG [32] and FR [31] from Table 2 in [31]. Here again, parallel TRGL has a better accuracy than the other two methods and than end-to-end training. With only two modules, the memory gains from less backpropagation are neutralized by the weight of the extra classifier and there are negligible memory savings compared to end-to-end training. However, parallel TRGL has a better test accuracy by up to almost 2 percentage points.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Architecture & Parallel VanGL & Parallel TRGL (ours) & PredSim & DGL & Sedona & E2E \\ \hline VGG-19 & 56.17 \(\pm\) 0.29 (\(\downarrow\)\(27\%\)) & **57.28 \(\pm\)** 0.20 (\(\downarrow\)\(21\%\)) & 44.70 & 51.40 & 56.56 & 58.74 \\ ResNet-50 & 58.43 \(\pm\) 0.45 (\(\downarrow\)\(26\%\)) & **60.30 \(\pm\)** 0.58 (\(\downarrow\)\(20\%\)) & 47.48 & 53.96 & 54.40 & 58.10 \\ ResNet-101 & 63.64 \(\pm\) 0.30 (\(\downarrow\)\(24\%\)) & **63.71 \(\pm\)** 0.40 (\(\downarrow\)\(11\%\)) & 53.92 & 53.80 & 59.12 & 62.01 \\ ResNet-152 & 63.87 \(\pm\) 0.16 (\(\downarrow\)\(21\%\)) & **64.23 \(\pm\)** 0.14 (\(\downarrow\)\(10\%\)) & 51.76 & 57.64 & 64.10 & 62.32 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Test accuracy of parallel TRGL with 4 modules (average and 95\(\%\) confidence interval over 5 runs) on TinyImageNet, compared to DGL, PredSim, Sedona and E2E from Table 2 in [47], with memory saved compared to E2E as a percentage of E2E memory consumption in red.
The third experiment is training in parallel a ResNet-110 divided into two, four, eight and sixteen modules on STL10 [12]. We compare in Table 3 our results in this setup to the recent methods InfoPro [60] and DGL [8] from Table 2 in [60]. TRGL largely outperforms the other methods. It also outperforms end-to-end training in all but one case (that with 16 modules). With a batch size of 64, memory savings of parallel TRGL compared to end-to-end training reach \(48\%\) and \(58.5\%\) with 8 and 16 modules respectively, with comparable test accuracy. With 4 modules, TRGL training weighs \(24\%\) less than end-to-end-training, and has a test accuracy that is better by \(2\) percentage points (see Section 4.2 and Table 5 for a detailed memory usage comparison with InfoPro).

The fourth experiment is training (from scratch) in parallel a Swin-Tiny Transformer [39] divided into 4 modules on three datasets. We compare in Table 4 our results with those of InfoPro [60] and InfoProL, a variant of InfoPro proposed in [46]. TRGL outperforms the other module-wise training methods. It does not outperform end-to-end training in this case, but consumes \(29\%\) less memory on CIFAR10 and CIFAR100 and 50\(\%\) less on STL10, compared to \(38\%\) for InfoPro and \(45\%\) for InfoProL in [46].

### Memory savings

As seen above, parallel TRGL is lighter than end-to-end training by up to almost \(60\%\). The extra memory consumed by our regularization compared to parallel VanGL is between 2 and \(13\%\) of end-to-end memory. Memory savings depend then mainly on the size of the auxiliary classifier, which can easily be adjusted. Note that delayed gradients method DDG and FR increase memory usage [31], and Sedona does not claim to save memory, but rather to speed up training [47]. DGL is architecture-wise essentially identical to VanGL and consumes the same memory.

We compare in Table 5 the memory consumption of our method to that of InfoPro [60] on a ResNet-110 on STL10 with a batch size of 64 (so the same setting as in Table 3). InfoPro [60] also propose to split the network into modules that have the same weight but not necessarily the same number of layers. They only implement this for \(K{\leq}4\) modules. When the modules are even in weight and not in depth, we call the training methods VanGL*, TRGL* and InfoPro*. In practice, this leads to shallower early modules which slightly hurts performance according to [47], and as seen below.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Dataset & Parallel VanGL & Parallel TRGL (ours) & InfoPro & InfoProL & E2E \\ \hline STL10 & 67.00 \(\pm\) 1.36 (\(\downarrow\) 55\%) & **67.92**\(\pm\) 1.12 (\(\downarrow\) 50\%) & 64.61 (\(\downarrow\) 38\%) & 66.89 (\(\downarrow\) 45\%) & 72.19 \\ CIFAR10 & 83.94 \(\pm\) 0.42 (\(\downarrow\) 33\%) & **86.48**\(\pm\) 0.54 (\(\downarrow\) 29\%) & 83.38 (\(\downarrow\) 38\%) & 86.28 (\(\downarrow\) 45\%) & 91.37 \\ CIFAR100 & 69.34 \(\pm\) 0.91 (\(\downarrow\) 33\%) & **74.11**\(\pm\) 0.31 (\(\downarrow\) 29\%) & 68.36 (\(\downarrow\) 38\%) & 73.00 (\(\downarrow\) 45\%) & 75.03 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Test accuracy of parallel TRGL with 4 modules (average and 95\(\%\) confidence interval over 5 runs) on a Swin-Tiny Transformer, compared to InfoPro, InfoProL and E2E from Table 3 in [46], with memory saved compared to E2E as a percentage of E2E memory consumption in red.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Architecture & Parallel VanGL & Parallel TRGL (ours) & DDG & FR & E2E \\ \hline ResNet-101 & 77.31 \(\pm\) 0.27 & **77.87**\(\pm\) 0.44 & 75.75 & 76.90 & 76.52 \\ ResNet-152 & 75.40 \(\pm\) 0.75 & **76.55**\(\pm\) 1.90 & 73.61 & 76.39 & 74.80 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Test accuracy of parallel TRGL with 2 modules (average and 95\(\%\) confidence interval over 3 runs) on CIFAR100, compared to DDG, FR and E2E from Table 2 in [31].
However, TRGL* still outperforms InfoPro and end-to-end training, and it leads to even bigger memory savings than InfoPro*. We see in Table 5 below that TRGL saves more memory than InfoPro in two out of three cases (4 and 8 modules), and about the same in the third case (16 modules), with much better test accuracy in all cases. Likewise, TRGL* is lighter than InfoPro*, with better accuracy. See Appendix F for more details.

### Training time

Since we do not implement forward unlocking with batch buffers as in DGL (i.e. only the backward passes of the modules happen in parallel), parallel module-wise training does slightly slow down training in this case. Epoch time increases by \(6\%\) with 2 modules and by \(16\%\) with 16 modules. TRGL is only slower than VanGL by \(2\%\) for all number of modules due to the additional regularization term. This is comparable to InfoPro which reports a time overhead between 1 and \(27\%\) compared to end-to-end training.

### Sequential full block-wise training

Block-wise sequential training, meaning that each module is a single residual block and that the blocks are trained sequentially, therefore requiring only enough memory to train one block and its classifier. Even though it has been less explored in recent module-wise training methods, it has been used in practice in very constrained settings such as on-device training [58; 57]. We therefore test our regularization in this section in this setting, with more details in Appendix G.

We propose here to use shallower ResNets that are initially wider. These architectures are well-adapted to layer-wise training as seen in [7]. We check first in Table 9 in Appendix G that this architecture works well with parallel module-wise training with 2 modules by comparing it favorably on CIFAR10 [37] with methods DGL [8], InfoPro [60] and DDG [32] that use a ResNet-110 with the same number of parameters.

We then train a 10-block ResNet block-wise on CIFAR100. In Tables 10 and 11 in Appendix G, we see that MLS training improves the accuracy of sequential training by \(0.8\) percentage points when the trainset is full, but works less well on small train sets. Of the two, the regularization mainly improves the test accuracy of MLS training. The improvement increases as the training set gets smaller and reaches 1 percentage point. While parallel module-wise training performs quite close to end-to-end training in the full data regime and much better in the small data regime, sequential and multi-lap sequential training are competitive with end-to-end training in the small data regime. Combining the multi-lap trick and the regularization improves the accuracy of sequential training by 1.2 percentage points when using the entire trainset. We report further results for full block-wise training on MNIST [38] and CIFAR10 [37] in Tables 12 and 13 in Appendix G.

The \(88\%\) accuracy of sequential training on CIFAR10 in Table 12 is the same as in Table 2 of [7], which is the best method for layer-wise sequential training available, with VGG networks of comparable depth and width.
On the left, from parallel module-wise training experiments from Table 3, TRGL performs worse than vanilla greedy learning early, but surpasses it in later modules, indicating that it does avoid early overfitting. On the right, from sequential block-wise training experiments from Table 12, we see a large decline in performance that the regularization avoids. We see similar patterns in Figure 3 in Appendix G with parallel and MLS block-wise training.

## 5 Limitations

The results in Appendix G show a few limitations of our method, as the improvements from the regularization are sometimes minimal on sequential training. However, the results show that our approach works in all settings (parallel and sequential with many or few modules), whereas other papers don't test their methods in all settings, and some show problems in other settings than the original one in subsequent papers (e.g. delayed gradients methods when the number of modules increases [31] and PredSim in [47]). Also, for parallel training in Section 4.1, the improvement from the regularization compared to VanGL is larger and increases with the number of modules (so with the memory savings) and reaches almost 5 percentage points. We show in Appendix H that our method is not very sensitive to the choice of hyperparameter \(\tau\) over a large scale.

## 6 Related work

Layer-wise training was initially considered as a pre-training and initialization method [10; 43] and was recently shown to be competitive with end-to-end training [7; 45]. Many papers consider using a different auxiliary loss, instead of or in addition to the classification loss: kernel similarity [42], information-theory-inspired losses [53; 44; 41; 60] and biologically plausible losses [53; 45; 25; 11]. Methods [7], PredSim [45], DGL [8], Sedona [47] and InfoPro [60] report the best module-wise training results. [7; 8] do it simply through the architecture choice of the auxiliary networks. Sedona applies architecture search to decide on where to split the network into modules and what auxiliary classifier to use before module-wise training. Only BoostResNet [30] also proposes a block-wise training idea geared for ResNets. However, their results only show better early performance and end-to-end fine-tuning is required to be competitive. A method called ResIST [19] that is similar to block-wise training of ResNets randomly assigns ResBlocks to one of up to 16 modules that are trained independently and reassembled before another random partition. More of a distributed training method, it is only compared to local SGD [54]. These methods can all be combined with our regularization, and we do use the auxiliary classifier from [7; 8].

Besides module-wise training, methods such as DNI [33; 14], DDG [32] and FR [31], solve the update and backward locking problems with an eye towards parallelization by using delayed or predicted gradients, or even predicted inputs to address forward locking, which is what [55] do. But they observe training issues with more than 5 modules [31]. This makes them compare unfavorably to module-wise training [8]. The high dimension of the predicted gradient, which scales with the

Figure 2: Test accuracy after each module averaged over 10 runs with \(95\%\) confidence intervals. Left: parallel vanilla (VanGL, in blue) and regularized (TRGL, in red) module-wise training of a ResNet-110 with 16 modules on STL10 (Table 3). Right: sequential vanilla (VanGL, in blue) and regularized (TRGL, in red) block-wise training of a 10-block ResNet on \(2\%\) of CIFAR10 (Table 12).
size of the network, makes [33; 14] challenging in practice. Therefore, despite its simplicity, greedy module-wise training is more appealing when working in a constrained setting.

Viewing ResNets as dynamic transport systems [16; 36] followed from their view as a discretization of ODEs [61]. Transport regularization of ResNets in particular is motivated by the observation that they are naturally biased towards minimally modifying their input [35; 26]. We further linked this transport viewpoint with gradient flows in the Wasserstein space to apply it in a principled way to module-wise training. Gradient flows on the data distribution appeared recently in deep learning. In [1], the focus is on functionals of measures whose first variations are known in closed form and used, through their gradients, in the algorithm. This limits the scope of their applications to transfer learning and similar tasks. Likewise, [21; 40; 4; 3] use the explicit gradient flow of \(f\)-divergences and other distances between measures for generation and generator refinement. In contrast, we use the discrete minimizing movement scheme which does not require computation of the first variation and allows to consider classification.

## 7 Conclusion

We introduced a transport regularization for module-wise training that theoretically links module-wise training to gradient flows of the loss in probability space. Our method provably leads to more regular modules and experimentally improves the test accuracy of module-wise parallel, sequential and multi-lap sequential (a variant of sequential training that we introduce) training. Through this simple method that does not complexify the architecture, we make module-wise training competitive with end-to-end training while benefiting from its lower memory usage. Being a regularization, the method can easily be combined with other layer-wise training methods. Future work can experiment with working in Wasserstein space \(W_{p}\) for \(p\neq 2\), i.e. regularizing with a norm \(\|.\|_{p}\) with \(p\neq 2\). One can also ask how far the obtained composition network \(G_{K}\) is from being an OT map itself, which could provide a better stability bound than the one obtained by naively chaining the stability bounds (8).
