BGPFA

Variational Bayesian GPFA with ARD and differentiable ELBO training.

Source

  • Registry name: bgpfa
  • Model class: ladys.models.bgpfa.BGPFA
  • Config class: ladys.models.bgpfa.BGPFAConfig
  • Source file: src/ladys/models/bgpfa.py

When to use

Use BGPFA when you want the Bayesian GPFA objective from tachukao/mgplvm-pytorch inside the LaDyS trainer contract. Unlike the classical GPFA EM baseline, this adapter optimizes a Monte Carlo variational negative ELBO with standard PyTorch backpropagation.

Assumptions

Observations are passed as (batch, time, neurons) tensors and internally transposed to mgplvm's (trials, neurons, time) convention. The latent posterior has per-trial variational parameters, so the default optimization strategy is mgplvm_full_batch_gradient. One LaDyS epoch can run multiple mgplvm optimizer updates via optimization.steps_per_epoch; this is useful when matching reference bGPFA scripts that report fixed optimizer-step budgets.

Outputs

forward returns predictive rates/reconstructions, variational latent means, and ELBO terms in extras. The core mgplvm implementation is vendored in src/mgplvm; this class only adapts it to the LaDyS model, loss, and trainer contracts.

Configuration

Config for variational Bayesian GPFA.

Field Type Default
name Literal['bgpfa'] 'bgpfa'
objective str 'negative_elbo'
latent_dim int 3
binsize float 25.0
ell0 Optional[float] None
rho float 2.0
n_mc_train int 3
n_mc_eval int 5
kl_burnin_epochs int 1
latent_scale_init float 1.0
likelihood Literal['gaussian', 'poisson'] 'gaussian'
learn_scale bool False
ard bool True
dtype Literal['float64', 'float32'] 'float64'
optimization OptimizationConfig OptimizationConfig(name='mgplvm_full_batch_gradient', optimizer='Adam', lr=0.1, steps_per_epoch=1, burnin=150, n_mc=3, weight_decay=0.0)

Contracts