Representation learning for neural population activity with Neural Data Transformers

Joel Ye, Chethan PandarinatharXiv 2021

Introduction

Understanding the neural basis of movement requires modeling the "dynamics" of neural populations—the complex rules governing how activity evolves over time. For years, the gold standard for this task has been LFADS (Latent Factor Analysis via Dynamical Systems), a framework built on Recurrent Neural Networks (RNNs). While highly accurate, RNNs are inherently sequential: to calculate the neural state at any given time $t$, the model must first process every preceding timestep. This sequential bottleneck limits the "loop time" of real-time brain-computer interfaces (BCIs) and closed-loop neural stimulators.

The Neural Data Transformer (NDT) addresses this challenge by moving away from explicit recurrence. By adapting the self-attention mechanisms popularized in natural language processing (NLP), the NDT processes entire windows of neural activity in parallel, achieving state-of-the-art accuracy with significantly lower latency.

The Neural Data Transformer Architecture

The core innovation of the NDT is the replacement of sequential RNN units with a parallel Transformer architecture. Unlike LFADS, which uses an encoder-decoder RNN structure to infer latent factors, the NDT uses self-attention to weigh the importance of different timepoints across a trial simultaneously.

Comparison between the parallel Neural Data Transformer (NDT) and the sequential LFADS architecture.

As shown in the comparison above, the NDT architecture allows for a direct mapping from observed spikes to inferred population states. This parallelization enables an inference latency of just 3.9ms, representing a 6.7x speedup over recurrent baselines on standard motor cortex datasets. Such speeds are critical for BCIs, where minimizing the delay between neural intent and device action is paramount for user performance.

Technical Innovations and Methods

Adapting Transformers—originally designed for text—to neural spiking data required several key technical modifications:

  • Self-Attention for Dynamics: The model uses multiple Transformer layers to learn temporal dependencies. Each layer consists of multi-head self-attention and feed-forward networks, allowing the model to capture the autonomous dynamics of the population without needing a sequential state update.
  • Zero-Masking for Unsupervised Learning: To train without labels, the authors used "masked modeling." While NLP models use a special [MASK] token, the NDT uses a "zero mask" (setting spike counts to zero). This prevents a distribution shift between training and real-time inference, where the model must handle actual zero-spike intervals.
  • Poisson Likelihood and Log-Rates: Because neurons fire in discrete spikes, the standard MSE loss was replaced with a Poisson likelihood objective. Crucially, the model predicts log-firing rates. The authors found that constraining the model to work in log-space was essential for stable training, as the network otherwise struggled to learn the necessary exponentiation internally.
The internal structure of the NDT, highlighting the self-attention mechanism and transformer layers.

Results and Performance

The NDT was validated on both synthetic chaotic systems (Lorenz) and real-world biological data (Monkey J Maze reaching task).

  • Decoding Accuracy: On the Monkey J dataset (202 neurons), the NDT achieved a kinematic decoding $R^2$ of 0.918, matching the performance of AutoLFADS (0.915). This demonstrates that explicit recurrence is not necessary to capture high-fidelity neural dynamics.
  • Data Efficiency: Despite the reputation of Transformers requiring massive datasets, the NDT proved robust on small neuroscience datasets. Using aggressive dropout (up to 60%), the model remained performant even with as few as 92 trials, outperforming traditional spike-smoothing methods.

Limitations and Future Outlook

The current NDT is optimized for autonomous dynamics, where the future state depends primarily on the internal state of the population. In scenarios involving unpredictable external sensory inputs or perturbations (non-autonomous dynamics), LFADS still maintains a performance lead of approximately 20%.

Future iterations of the NDT may incorporate cross-attention mechanisms to explicitly handle external inputs or utilize large-scale "pre-training" on unlabeled neural data to further improve performance on specialized tasks. By proving that parallel architectures can match the accuracy of recurrent models, the NDT opens a new path for high-performance, low-latency neural engineering.

Summary updated

BibTeX
@misc{ye2021representation,
  author = {Joel Ye and Chethan Pandarinath},
  title = {{Representation learning for neural population activity with Neural Data Transformers}},
  year = {2021},
  eprint = {2108.01210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.01210},
}
Figure