GPFA
Gaussian Process Factor Analysis with diagonal observation noise.
Source
- Registry name:
gpfa - Model class:
ladys.models.gpfa.GPFA - Config class:
ladys.models.gpfa.GPFAConfig - Source file:
src/ladys/models/gpfa.py
When to use
Use GPFA as a classical latent-variable baseline for neural population
activity with smooth low-dimensional trajectories. The default LaDyS
adapter optimizes the exact marginal negative log likelihood with standard
PyTorch backpropagation. The original EM-style update remains available by
setting optimization.name to em.
Assumptions
Observations are modeled with Gaussian noise, a linear loading matrix, a per-neuron offset, diagonal private noise, and RBF Gaussian-process priors over latent trajectories.
Outputs
forward returns posterior latents, observation-space reconstructions,
nonnegative rate estimates, orthonormalized latent diagnostics, and the
differentiable marginal log likelihood used by the loss.
Synthetic datasets
On synthetic datasets, GPFA is evaluated through the default synthetic adapter. The model returns inferred rates and latents, and LaDyS compares them against dataset-provided ground-truth rates and latent states when those targets are available.
ladys run -c configs/experiment/synthetic/lorenz/gpfa/gpfa_lorenz.yaml
The resulting run folder contains metrics.json with synthetic metrics
such as rate reconstruction quality and latent linear R2 when the target
tensors match the returned output shapes.
Real NLB datasets
On real NLB datasets, GPFA keeps the same model-native forward output,
but evaluation uses GPFA.evaluation_adapter("nlb"). The adapter fits a
PyTorch Poisson readout from training-set GPFA latents to training held-out
neurons, then scores eval held-out expected counts with the NLB
co-smoothing bits/spike metric.
Prepare the NLB H5 first, then run the real-data config:
ladys prepare-nlb --datasets mc_maze --splits test --bin-sizes-ms 5 --download
ladys run -c configs/experiment/real/mc_maze/gpfa/gpfa_mc_maze_nlb_5ms.yaml
ladys score-nlb --run-dir runs/gpfa_mc_maze_nlb_5ms
This real-data path reports held-out co_bps and writes held-out rate
predictions in predictions.npz; it does not require GPFA itself to emit
held-out-neuron rates directly.
Initialization
Trainable observation parameters are torch.nn.Parameters: C, d,
log_R_diag, and optionally log_gamma. init_method controls the initial
C loading matrix. Orthonormalization is only returned in extras for
diagnostics and plotting; it is not copied back into the trainable
parameters.
Configuration
Config for Gaussian-observation GPFA.
| Field | Type | Default |
|---|---|---|
name |
Literal['gpfa'] |
'gpfa' |
objective |
str |
'negative_log_marginal_likelihood' |
latent_dim |
int |
3 |
bin_width |
float |
20.0 |
start_tau |
float |
100.0 |
start_eps |
float |
0.001 |
min_var_frac |
float |
0.01 |
init_method |
Literal['fa', 'normal', 'kaiming', 'kaiming_normal', 'kaiming_uniform'] |
'kaiming_normal' |
init_seed |
Optional[int] |
None |
learn_kernel_params |
bool |
True |
fa_max_iters |
int |
500 |
fa_tol |
float |
1e-08 |
kernel_param_max_iters |
int |
8 |
kernel_param_lr |
float |
1.0 |
jitter |
float |
1e-05 |
optimization |
OptimizationConfig |
OptimizationConfig(name='gradient', optimizer='Adam', lr=0.01, weight_decay=0.0, gradient_clip=100.0) |
Contracts
forwardinputs use(batch, time, neurons)observations.- Runtime outputs follow the model output contract.
- Optimizer epochs follow the optimizer contract.