Abstract
Hidden Markov Models (HMMs) are widely used in neuroscience to segment
natural behavior into sequences of discrete latent states with stochastic transitions. However, both neural
activity and behavior evolve in continuous state spaces, suggesting that such discrete assumptions may
oversimplify the underlying dynamics. Recurrent Neural Networks (RNNs), by contrast, can capture continuous
neural dynamics but are typically studied in deterministic, input-driven tasks. It remains unclear whether
RNNs can reproduce the spontaneous, stochastic dynamics characteristic of natural behavior. We show that
RNNs can emulate the discrete, probabilistic dynamics of HMMs. Reverse-engineering the trained networks
reveals a dynamical motif organized in orbital trajectories, where noise-sustained rotation modulates the
emitted output through transitions between regions of slow, stochastic dynamics connected by fast,
deterministic flows. The trained RNNs develop highly-structured connectivity, with large neuronal
populations integrating input-noise and triggering a small set of “kick-neurons” which initiate transitions
between slow-regions, operating in a regime of stochastic resonance. RNNs generalize across HMM
architectures by composing this dynamical primitive to emulate complex discrete dynamics. Applied to
Drosophila courtship behavior data, the same dynamical motif emerges, with discrete clusters corresponding
to behavioral modes and stochastic transitions between them. Unlike HMMs, we show that RNNs recover richer
latent structures with both discrete and continuous features.