mixle.ppl.neural module¶
Neural conditional models for mixle.ppl – a Net predictor in a slot.
The nonlinear sibling of mixle.ppl.regression. A Net in an outer family’s slot makes a neural
conditional model; the outer family sets the link:
Categorical(logits=Net(out=K)).fit(y, given={"x": X}) # softmax link -> classification (SoftmaxNeuralLeaf)
Normal(Net(out=1), free).fit(y, given={"x": X}) # identity link -> neural mean + learned noise (the blend)
The objective is the leaf’s own log-density; fitting routes to the standard
mixle.inference.estimate() loop – there is no loss function and no training loop in user code.
- class NeuralResult(dist, field, kind)[source]
Bases:
objectA fitted neural conditional model.
predict(given={"x": X})returns class labels (Categorical) or the conditional mean (Normal) at new covariates – the same shape of interface asRegressionResult.predict..distis the underlying mixle leaf (composes into mixtures / composites like any distribution).- predict(given)[source]
Class labels (Categorical) or the conditional mean (Normal) at covariates
given.
- neural_fit(rv, data, *, given=None, epochs=200, lr=0.01, batch_size=None, device='cpu', init=None, weights=None, ewc=None, **_)[source]
Fit a neural-headed conditional RV.
datais the responsey;givencarries the covariates.epochsis the number of passes;batch_size(None = full batch) +device(“mps”/”cuda”) let a conv net train on a real image set on the GPU. The input keeps its natural shape – (N, D) or (N, C, H, W).Multi-stage pipeline (one module across stages):
init=continues a previous fit’s module (CPT/SFT) instead of building a fresh one;weights=are per-observation loss weights (e.g. an SFT prompt mask: 0 on prompt tokens, 1 on the completion);ewc=is an(anchor, fisher, lambda)EWC penalty for continued pretraining without forgetting.