This repository contains the code for the Lorenz and task-learning experiments in our ICLR 2026 paper on inferring brain plasticity. It implements STEER, a low-rank recurrent-dynamics framework for modelling how stimulation drives changes in neural dynamics across trials.
The code was developed with Python 3.10+ and PyTorch. Create an environment of your choice, then install:
pip install torch numpy scipy matplotlib scikit-learn tqdm geotorchRun the notebooks from the repository root so their relative paths resolve correctly:
jupyter labGPU acceleration is used automatically when a CUDA-enabled PyTorch installation is available; otherwise the notebooks run on CPU.
Open and run trainer-Lorenz_with_STEER.ipynb. The required simulated data are included at:
data/lorenz_data_sigma_init_10_rho_init_48_scale_10_amp_1_beta_init_3.50_freq_10_amp_1.00.pt
The provided configuration uses a rank-3 model with hidden dimension 28. By default, it runs ten random seeds for 1,000 epochs each, reports explained variance, and saves checkpoints under checkpoints_newdata/Lorenz/different_rank/. Set with_cr_pred = True in the notebook to enable the cross-trial prediction loss used by STEER.
Open and run trainer-Task_learning_with_STEER.ipynb. The task-learning data are not distributed in this repository. Place the experiment .mat file at:
task_learning_data/learning_process_with_stimulation_induced_plasticity_total_cycles_2000.mat
The file must provide the variables inital_J, trial_dynamics, input_sequences, and delta_J. The notebook uses trials 100--1599, the first 20 neurons, a rank-5 model, and a 60/40 train/test split. Outputs are written under checkpoints_newdata/Task_learning_50/different_rank/.
trainer-Lorenz_with_STEER.ipynb # Lorenz experiment and trajectory plots
trainer-Task_learning_with_STEER.ipynb # stimulation-driven task-learning experiment
longitudinal_dynamics.py # STEER model wrapper and losses
LtrRNN.py # low-rank, trial-varying RNN dynamics
cr_RNN.py # cross-trial recurrent predictor
train_test_model.py # training, early stopping, and evaluation
DataSample.py # segmentation and dataset utilities
baseline/ # baseline implementations
The main STEER pipeline follows the paper's progression from trial-wise observations, to a low-dimensional representation of plasticity, to trial-varying recurrent dynamics. The files map to that pipeline as follows:
| File | Role in the paper's method |
|---|---|
longitudinal_dynamics.py |
The top-level STEER model. It combines the activity encoder, cross-trial latent dynamics, and recurrent dynamical system, and forms the reconstruction/dynamics loss together with the cross-trial prediction loss. |
mlp.py |
Neural encoders used to map each trial's observed activity to a latent representation and to infer hidden neural states before dynamical rollout. |
cr_RNN.py |
The cross-trial RNN that models the evolution of the low-dimensional plasticity representation. In task learning, it also receives the stimulation/input sequence. |
DynamicalSystem.py |
Rolls out neural activity within each trial using the trial-specific recurrent dynamics; TF_interval controls the teacher-forcing reset interval. |
LtrRNN.py |
The core low-rank, trial-varying recurrent-weight parameterization. It constructs a recurrent matrix for each trial from shared factors and trial coefficients, and contains rational-quadratic-kernel machinery for trial-smooth coefficients. |
methods.py |
Small mathematical utilities used by the model, including the rational-quadratic kernel and trial-wise tensor multiplication. |
DataSample.py |
Splits consecutive trials into training/test batches and packages the optional stimulation signal for the task-learning experiment. |
train_test_model.py |
Optimisation and evaluation loop: combines the dynamics and cross-trial losses, applies early stopping, and reports explained variance, R², and MSE. |
ParamsInference.py |
A standalone prototype for inferring subject-specific parameters through shared projections. It is not called by the two primary STEER notebooks. |
trainer-Lorenz_with_STEER.ipynb |
Paper experiment: reconstruction and generalisation on the time-varying Lorenz system. |
trainer-Task_learning_with_STEER.ipynb |
Paper experiment: stimulation-driven task learning, including recovery of evolving recurrent connectivity. |
baseline/ |
Implementations of comparison models used for baseline experiments; they are not part of the main STEER training path above. |
If you use this code, please cite our ICLR 2026 paper (also available on arXiv):