Initialization recipes¶
init_spec
¶
Algebra-specific initialization recipes.
The Algebra's tensor / join operations determine where in
its value space a k-step composition lands when entries are
i.i.d. and roughly mean-zero. For each built-in algebra we record
the parameters of a one-dimensional initial distribution that
places the k-step output in a reference region where the closed-form
approximation predicts larger gradients. The shipped recipes are:
ProductFuzzyAlgebra— noisy-OR overkcells lands at ½ when each cell is initialized atp ≈ ln 2 / k.LogProbAlgebra— log-domain; centered at-ln kso the exponentiated value is1 / k.MarkovAlgebra— row logits centered at 0 (uniform prior over the row simplex).MaxPlusAlgebra/TropicalAlgebra— additive semiring on the (extended) reals; centered at 0 with spread1 / sqrt(k).LukasiewiczAlgebra— bounded-sum t-conorm hits ½ at roughlykterms ofp ≈ 1 / k.BooleanAlgebra,GodelAlgebra— idempotent; init at the algebra's mid-point0.5.RealAlgebra,ProbabilityAlgebra,CountingAlgebra— sum-product semirings; we recommend unit-variance Normal init centered at 0 (real) or an algebra-specific1 / k(probability / counting). These pieces are conservative defaults pending a fuller writeup of the semiring case.
The InitSpec produced by Algebra.init_spec is
distribution-shaped (mean, std, lower, upper, distribution name).
Sampling itself is delegated to torch.nn.init via
apply_init_spec.
InitSpec
didactic-model
¶
InitSpec(*, distribution: Literal['normal', 'uniform', 'constant'] = 'normal', mean: float = 0.0, std: float = 1.0, lower: float = float('-inf'), upper: float = float('inf'), rationale: str = '')
Bases: Model
Parameters of a one-dimensional initial distribution.
| ATTRIBUTE | DESCRIPTION |
|---|---|
distribution |
One of
TYPE:
|
mean |
Location parameter for
TYPE:
|
std |
Scale parameter for
TYPE:
|
lower, upper |
Bounds for
TYPE:
|
rationale |
One-line explanation of the recipe, suitable for surfacing
in a warning or in
TYPE:
|
recommend_init
¶
Per-latent algebra-specific initialization recipe.
Walks the program's ChainShape, looks up the governing
algebra, and returns a mapping from latent variable name to the
InitSpec that places the chain at the algebra's
mid-saturation point at depth-and-size.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed QVR module whose program is analysed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, InitSpec]
|
The recipe for each latent, keyed by variable name; empty when the module declares no governing algebra. |
Source code in src/quivers/analysis/init_spec.py
apply_init_spec
¶
Materialize an InitSpec onto a learnable tensor.
Delegates to torch.nn.init for normal / uniform and
to a plain fill_ for constant. The tensor's shape is
preserved; only its entries are overwritten in-place.
| PARAMETER | DESCRIPTION |
|---|---|
parameter
|
The tensor to overwrite in place.
TYPE:
|
spec
|
The recipe to draw the new entries from.
TYPE:
|