Trained recurrent neural networks develop phase-locked limit cycles in a working memory task

Matthijs Pals, Jakob H. Macke, Omri Barak

Abstract

Neural oscillations are ubiquitous in the brain and are hypothesized to serve as an internal clock for phase-coding information. However, the dynamical mechanisms supporting such coding remain unclear. We trained recurrent neural networks (RNNs) on a working memory task requiring the maintenance of phase offsets relative to a reference oscillation. By reverse-engineering these networks, we discovered that they develop stable oscillatory dynamics where each memory corresponds to a separate limit cycle attractor. These dynamics arise from the coupling of an internal oscillation to the external reference. Our findings provide a theoretical framework for how neural circuits can harness oscillations for robust working memory.

Introduction: The Functional Role of Brain Waves

Neural oscillations, or "brain waves," are observed across numerous brain regions, yet their functional purpose is a subject of ongoing debate. A leading hypothesis is phase coding: the idea that information is encoded by the timing of neural activity relative to the phase of an ongoing rhythm. While empirical evidence for phase coding exists—most notably in the hippocampus—the underlying dynamical "machinery" that allows a population of neurons to maintain a specific phase offset as a memory is not well understood.

This study uses artificial RNNs as "hypothesis generators" to investigate the dynamical systems that make phase-based working memory possible. We ask: What kind of connectivity and state-space dynamics allow a network to "lock" onto a rhythm and preserve that relationship even after a stimulus disappears?

Methods: Training and Reverse-Engineering Low-Rank RNNs

We trained continuous-time RNNs to perform a phase-based working memory task. The networks were provided with a "reference oscillation" (acting as an external clock) and transient input pulses (stimuli $a$ or $b$). The objective was to produce an output oscillation that maintained a specific phase relationship to the reference—for example, in-phase for stimulus $a$ and anti-phase for stimulus $b$—long after the stimulus ended.

To make the resulting high-dimensional dynamics interpretable, we applied a low-rank constraint (rank-2) to the recurrent weight matrix $J$. This mathematical simplification allowed us to project the activity of hundreds of neurons into a tractable low-dimensional phase space.

Overview of the task and network architecture. (A) The RNN receives a reference oscillation and transient stimuli, producing a phase-locked output. (C) The connectivity matrix is decomposed into a low-rank structure. (D-E) The resulting dynamics can be visualized as vector fields on a plane or torus.

Key Insights: Memories as Limit Cycle Attractors

Traditionally, working memory in RNNs is modeled as "fixed-point attractors," where the network settles into a static state. Our analysis reveals a different paradigm: memories as limit cycle attractors. In these networks, a memory is not a static point but a stable, repeating loop in state space.

We found that the trained RNNs effectively split into two functional modules: one that generates an autonomous internal oscillation and another that implements a coupling function. This function acts like a set of gears, locking the internal clock to the external reference at specific, stable angles. Depending on the initial stimulus, the network's internal state "falls" into one of several stable phase-locked orbits.

Visualization of limit cycle dynamics. (E) Phase-coded memories correspond to stable loops in the network's state space. (F) The network develops a multi-stable landscape where different memories occupy distinct oscillatory orbits.

Results and Stability Islands

Reverse-engineering the trained networks allowed us to reduce a complex system of 512 units down to a simplified model of just three equations that perfectly captured the phase-locking behavior. We observed that the stability of these memories is highly sensitive to the reference oscillation's amplitude and frequency. We mapped out "islands of stability" in parameter space, providing a testable prediction for experimentalists: if an external rhythm is driven too fast or becomes too weak, phase-coded memories should collapse.

Furthermore, the model successfully replicated "phase precession," a biological phenomenon where neurons fire at progressively earlier phases of a theta cycle. In our model, this emerges naturally from a tonic shift in the coupling function.

Discussion

While the low-rank approach provides clarity, biological brains are likely higher-rank and more complex. However, we demonstrated that unconstrained networks develop similar dynamics, suggesting that the "two-clock" coupling mechanism is a robust solution for phase-based memory. Future work will focus on extracting these coupling functions directly from experimental neural data to see if the predicted "islands of stability" match animal behavior during cognitive tasks.

Summary updated

BibTeX
@article{pals2024trained,
  author = {Matthijs Pals and Jakob H. Macke and Omri Barak},
  title = {{Trained recurrent neural networks develop phase-locked limit cycles in a working memory task}},
  journal = {PLOS Computational Biology},
  year = {2024},
  doi = {10.1371/journal.pcbi.1011852},
}
Figure