mixle.ppl.density module¶
Neural densities for mixle.ppl – flexible p(x) and p(y | x) as first-class PPL constructors.
The nonlinear sibling of the plain distribution constructors. mixle.ppl.neural puts a neural predictor
(Net/Conv/Transformer) into an outer family’s slot, so the outer family still fixes the likelihood
shape (a Gaussian mean, softmax logits). These constructors instead make the neural model be the whole density:
Flow(dim=2).fit(x) # exact p(x) via a normalizing flow VAE(dim=8, latent=2).fit(x) # latent-variable p(x) (ELBO) DiscreteAR(dim=5, cats=4).fit(x) # exact p(x) over discrete vectors EBM(dim=2).fit(x) # energy-based p(x) (NCE-trained, approximately normalized) MDN(x_dim=1, y_dim=1).fit(y, given={“x”: X}) # multimodal p(y|x) CondFlow(x_dim=1, y_dim=2).fit(y, given={“x”: X}) # exact conditional p(y|x)
Each lowers to the composable NeuralDensity /
NeuralConditionalDensity leaf and fits through the same
optimize EM loop – no loss function, no training loop in user code. A fitted model is a bound
RandomVariable whose .dist is the leaf, so it drops into a Mix/composite like any distribution.
- Flow(dim, *, hidden=32, layers=4, m_steps=80, lr=5e-3)[source]
An exact
p(x)overR^dimvia a RealNVP coupling flow. Fit with.fit(x).
- MAF(dim, *, hidden=64, blocks=3, m_steps=80, lr=5e-3)[source]
An exact
p(x)overR^dimvia a masked autoregressive flow (richer dependence). Fit with.fit(x).
- VAE(dim, *, latent=2, hidden=32, m_steps=120, lr=5e-3)[source]
A latent-variable
p(x)overR^dimvia a VAE.log_densityis the ELBO (a lower bound); fit.fit(x).
- DiscreteAR(dim, cats, *, hidden=64, m_steps=100, lr=5e-3)[source]
An exact
p(x)over discrete vectorsx in {0..cats-1}^dim(autoregressive). Fit with.fit(x).
- EBM(dim, *, hidden=64, layers=3, noise_ratio=2, m_steps=250, lr=5e-3)[source]
An energy-based
p(x) ∝ exp(-E(x))overR^dim, trained by NCE (approximately normalized). Fit.fit(x).
- MDN(x_dim, y_dim, *, k=5, hidden=32, field='x', m_steps=120, lr=5e-3)[source]
A multimodal, heteroscedastic
p(y | x)via a mixture density network. Fit.fit(y, given={"x": X}).
- CondFlow(x_dim, y_dim, *, hidden=32, layers=4, field='x', m_steps=100, lr=5e-3)[source]
An exact conditional
p(y | x)via a conditional coupling flow (needsy_dim >= 2). Fit with covariates.
- CondDiscreteAR(x_dim, y_dim, cats, *, hidden=64, field='x', m_steps=120, lr=5e-3)[source]
An exact conditional
p(y | x)over discretey(autoregressive, conditioned onx). Fit w/ covariates.