MLPCategorical#
- class hybrid_aif.MLPCategorical[source]#
Bases:
ModuleMLP over concatenated parents → a factored categorical child.
num_varsindependent categoricals ofnum_classesclasses each, unimix-mixed and sampled as a straight-through one-hot. The child value is the one-hot code, shape(num_vars, num_classes);flat_dimis its width as a downstream parent. There is nomoments:probs()is this family’s moment view.- trunk: MLPPredictor#
The network from the concatenated parents to the
num_vars * num_classeslogits.
- classmethod from_shapes(
- parent_dims,
- num_vars,
- num_classes,
- *,
- key,
- width,
- depth=1,
- activation='silu',
- norm=True,
- unimix=0.01,
- frozen=False,
- init='default',
A randomly-initialized head:
depthnormed, activated hidden layers ofwidthunits (required), then a linear to thenum_vars·num_classeslogits.initis as inMLPPredictor.from_shapes().
- condition_on(parents)[source]#
The conditional as a
Categoricalwhose batch axis is the variable axis, so entropies and KLs come out per variable.
- log_prob(child, parents)[source]#
log q(child | parents)for a one-hot code, summed over variables.Σ_v Σ_c child[v,c]·log p[v,c]: differentiable through a straight-through sample, and finite for every code (unimix_logits()).
- __init__(trunk, num_vars, num_classes, unimix=0.01)#