arXiv:2610.26156cs.LGOct 2026

Manuscript Offprint

arXiv:2610.26156

Dynamical Batching: How Class-Cycling Training Shapes the Internal Structure of Neural Networks

Nicolás Ratier-Werbin, Samuel Lozano, Miguel Ruiz-García

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Nicolás Ratier-Werbin, 1,∗^{1,*} Samuel Lozano, 1,2,∗^{1,2,*} and Miguel Ruiz-García 1,2^{1,2}

1^{1}Departamento de Estructura de la Materia, Física Térmica y Electrónica,

Universidad Complutense de Madrid, 28040 Madrid, Spain

2^{2}Grupo Interdisciplinar de Sistemas Complejos, Universidad Complutense de Madrid, 28040 Madrid, Spain (Dated: October 20, 2026)

We investigate whether cyclically varying the class composition of training batches can modify both the performance and the internal organization of neural networks. Motivated by nonequilibrium systems, in which cycling between related sub-goals can make switching between their solutions increasingly efficient, we introduce Dynamical Batching (DB), a sampling protocol that periodically emphasizes each class while leaving the loss and the optimizer unchanged, and compare it with Uniform Batching (UB), in which every mini-batch has equal class proportions. In the regime where standard training fails, DB changes the outcome: on a three-arm spiral, a capacity-limited MLP that plateaus far below perfect accuracy under UB fits the training data under DB. Tracking individual weights, we find that under DB the change between class-specialized states is carried by a smaller set of weights than under UB, and that this set is markedly more persistent from cycle to cycle, on every synthetic dataset we test and in a wider network that fits the data under both protocols. This organization is a signature of the protocol rather than a predictor of its benefit: it appears equally where DB leaves accuracy unchanged. On CIFAR-10, the same protocol modestly improves the test accuracy of a channel-narrowed ResNet-10, a standard residual architecture, and of a second capacity-limited convolutional network. These results show that how class emphasis is distributed in time can shape both the solution a network reaches and the internal structure of the network.

I. INTRODUCTION

Neural networks are typically optimized under a fixed training objective, yet the trajectory followed to optimize that objective is itself part of the learning process. Choices such as the ordering of examples, curriculum, learning-rate schedule, optimizer, and batch construction can change which solutions are reached even when the final objective is unchanged [1−5][1-5]. This raises a broader question: how does a training protocol change not only which function a network learns, but also where in parameter space different parts of that function are implemented?

The question is particularly interesting for tasks that contain several related sub-problems. In a multiclass classifier, for example, a single network must implement class-specific decision rules while sharing a finite parameter budget. More generally, multitask learning asks a shared model to solve several objectives whose gradients may not point in the same direction. When task gradients conflict, optimizing their sum can produce inefficient or destructive interference, motivating methods that explicitly rebalance, project, or otherwise manipulate task gradients [6–8]. Continual-learning methods approach a related problem from the opposite temporal regime: when tasks are presented sequentially, parameter isolation, masks, pruning, or architectural expansion can protect task-specific computations from interference [9–14], and whether tasks are presented in blocks or interleaved changes what is learned [15]. These approaches demonstrate that which parameters are allowed to change is consequential, but they typically impose parameter isolation explicitly or address tasks one after another.

Here we study a different regime: the architecture and the objective are unchanged, but optimization pressure is deliberately cycled between related sub-problems. The protocol is closely related to dynamical loss functions [16, 17], an approach motivated by oscillating strategies in biological systems, materials science and physics [18–23], and distinct from learned, teacher-driven loss schedules [24]. A dynamical loss periodically changes the class weights of the cross-entropy loss, and this can rescue under-parametrized networks that fail under a static loss and can improve generalization in over-parametrized ones [16, 17]. This process can be analyzed through Hessian and neural-tangent-kernel dynamics [16]. Our questions are complementary: can a similar temporal forcing, implemented through mini-batch composition, rescue under-parametrized networks that fail under Uniform Batching (UB), in which every mini-batch has equal class proportions? And does it reorganize the parameters so that switching between class-specific solutions becomes more economical? Acting on batch composition rather than on the loss leaves the per-example loss and the optimizer untouched, so the protocol can be dropped into any training pipeline without modification.

This question connects to a broader literature on modularity. Modularity is commonly understood as an organization in which subsets of a system support distinguishable functions while interacting relatively weakly with other subsets. In neural networks, modularity can be defined structurally through connectivity [25] or functionally through subsets of weights required for particular com-

putations [26, 27]. Standard networks can exhibit some specialization without being explicitly modular, but the extent to which useful functional modules emerge from ordinary training remains an active question. In particular, Csordás et al. [26] found that common architectures often fail to reuse the same submodules across related functions, while work on superposition has emphasized that finite representational capacity can instead lead multiple features to share neurons or directions [28, 29]. We therefore do not assume that a network becomes modular in the graph-theoretic sense. Instead, we ask whether the parameter changes associated with switching between sub-problems become localized: a weaker notion than modularity, but a directly measurable one.

Our central hypothesis is that periodically emphasizing each class concentrates the class-to-class change of the network onto a small, stable set of weights. If so, moving from one class-specialized state to another should involve fewer weights, largely the same ones every time, and a shorter distance in parameter space. We test this prediction with three complementary measurements: the size of the switching set, the smallest fraction of weights that carries most of the class-to-class change; its persistence, the overlap between the switching sets of consecutive cycles; and the switching distance between class-specialized states.

We first map the operating regime of Dynamical Batching (DB) on a three-arm spiral, where a capacity-constrained MLP that plateaus under UB reaches near-perfect training accuracy under a suitable amplitude-period combination. We then follow the same training runs over time: the class-to-class change concentrates on a small set of weights that persists from cycle to cycle, while the distance between class-specialized states decreases, although the drift of ordinary training also decreases. Finally, we test whether the accuracy effect extends beyond the toy setting with a channel-narrowed ResNet-10 on CIFAR-10 and three further convolutional architectures. Our contributions are:

  1. A batch-level protocol that rescues a capacity-limited network. Without changing the loss, optimizer or architecture, DB lets a one-hidden-layer MLP that plateaus under UB fit the spiral; a grid over amplitude and period shows a broad region of gain bordered by a failure region.

  2. Weight-level measures of class switching. We define a drift-corrected switching set, its persistence, and a switching distance, and track them against a UB control that uses identical bookkeeping.

  3. Persistent, localized switching as a signature of the protocol. Under DB, the switching set is smaller and approximately twice as persistent as under UB across all five synthetic datasets, and the same pattern holds for a wider network that fits the data under both protocols.

  4. Evidence beyond the toy setting. On CIFAR-10, DB modestly improves the test accuracy of a channel-narrowed ResNet-10, acting as a regularizer; a plain CNN with a narrow fully connected bottleneck shows a similar gain, while two wider networks show none beyond seed-to-seed noise.