Stochastic Morphisms¶
Stochastic relations, kernels, and morphisms for probabilistic computation.
morphisms
¶
Stochastic morphisms: learnable Markov kernels via softmax.
Provides StochasticMorphism for row-stochastic linear maps and the stochastic() factory function.
StochasticMorphism
¶
Bases: Morphism
A learnable Markov kernel backed by softmax-normalized parameters.
Stores unconstrained real-valued logits and applies softmax along the codomain dimensions to produce a row-stochastic tensor (each fiber over a domain element sums to 1).
This is a morphism in FinStoch: a stochastic map A → B.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source object.
TYPE:
|
codomain
|
Target object.
TYPE:
|
temperature
|
Softmax temperature. Lower values → sharper distributions. Default 1.0.
TYPE:
|
Examples:
>>> A = FinSet(name="A", cardinality=3)
>>> B = FinSet(name="B", cardinality=4)
>>> f = StochasticMorphism(A, B)
>>> t = f.tensor # shape (3, 4), rows sum to 1
>>> t.sum(dim=-1) # tensor([1., 1., 1.])
Source code in src/quivers/stochastic/morphisms.py
48 49 50 51 52 53 54 55 56 57 58 59 60 | |
stochastic
¶
stochastic(domain: SetObject, codomain: SetObject, temperature: float = 1.0) -> StochasticMorphism
Create a learnable stochastic morphism (Markov kernel).
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source object.
TYPE:
|
codomain
|
Target object.
TYPE:
|
temperature
|
Softmax temperature.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StochasticMorphism
|
A learnable row-stochastic morphism. |
Source code in src/quivers/stochastic/morphisms.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |