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. Evaluation infers a new posterior from each
input batch with the learned observation model and GP prior held fixed.
The nlb_latent_infer_* options control this inference for both NLB and
synthetic evaluation. Predictions are expected counts per input bin.
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' |
latent_init |
Literal['gp_prior', 'fa'] |
'gp_prior' |
observation_init |
Literal['mgplvm', 'fa'] |
'mgplvm' |
nlb_feature_source |
Literal['latents', 'rates', 'reconstruction'] |
'latents' |
nlb_decoder |
Literal['ridge', 'poisson'] |
'poisson' |
nlb_ridge_alpha |
float |
0.01 |
nlb_poisson_max_iter |
int |
80 |
nlb_latent_infer_steps |
int |
300 |
nlb_latent_infer_n_mc |
int |
20 |
nlb_latent_infer_lr |
float |
0.1 |
nlb_latent_infer_burnin |
int |
1 |
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
forwardinputs use(batch, time, neurons)observations.- Runtime outputs follow the model output contract.
- Optimizer epochs follow the optimizer contract.