LFADS

Latent Factor Analysis via Dynamical Systems for binned spike counts.

Source

  • Registry name: lfads
  • Model class: ladys.models.lfads.LFADS
  • Config class: ladys.models.lfads.LFADSConfig
  • Source file: src/ladys/models/lfads.py

When to use

Use LFADS as a nonlinear variational sequence model for neural population spike counts. This implementation adapts the LFADS demo architecture into the LaDyS model contract: bidirectional encoders infer a generator initial condition and controller context, a generator GRU produces latent factors, and an exponential readout returns Poisson firing rates.

Assumptions

LFADS expects raw nonnegative spike counts. Dataset-level smoothing should be disabled for this model. The optional log1p encoder transform only changes the recognition network input; the reconstruction loss still uses raw counts and the returned rates remain in the generated Lorenz rate space. The default readout bias initialization uses observed count means, not generated ground-truth rates.

Outputs

forward returns nonnegative rate predictions, latent factor trajectories, and variational diagnostics in extras. loss computes a Poisson reconstruction objective plus scheduled KL and optional recurrent L2 terms.

Configuration

Config for LFADS on raw spike-count observations.

Field Type Default
name Literal['lfads'] 'lfads'
objective str 'lfads_elbo'
generator_dim int 64
inferred_input_dim int 2
factor_dim int 20
g0_encoder_dim int 64
controller_encoder_dim int 64
controller_dim int 64
g0_prior_kappa float 0.1
inferred_input_prior_kappa float 0.1
keep_prob float 0.95
clip_val float 5.0
dt float 1.0
log_rate_min float -8.0
log_rate_max float 8.0
posterior_logvar_min float math.log(0.0001)
posterior_logvar_max float 5.0
use_log1p_encoder_inputs bool True
initialize_log_rate_bias bool True
prediction_samples int 1
kl_weight_schedule_start int 0
kl_weight_schedule_dur int 2000
l2_weight_schedule_start int 0
l2_weight_schedule_dur int 2000
l2_gen_scale float 0.0
l2_con_scale float 0.0
optimization OptimizationConfig OptimizationConfig(name='gradient', optimizer='Adam', lr=0.001, weight_decay=0.0, gradient_clip=200.0)

Contracts