The flows' operations over ℝ #
The real functions behind the flow signature (RoleFlow.Flow.Basic), on flat vectors Vec n, and
the facts its leaves need: the reference measures of the gauss and unit sorts (Lebesgue
measure with the standard-normal and the logistic density), change of variables for invertible
matrices (through the Jacobian formula), for the elementwise odd powers (off the null set
of the axes) and for the changes of measure, and measurability of every conditioner. Ported from
SemiInv2; only the weights are now expw of a log-weight.
Splitting and joining #
Vec (m + n) cut into its first m and last n entries.
Equations
- RoleFlow.Flow.vsplit m n v = (fun (i : Fin m) => v (Fin.castAdd n i), fun (j : Fin n) => v (Fin.natAdd m j))
Instances For
Conditioners #
mvmul: a row-major m × n matrix against a vector.
Equations
- RoleFlow.Flow.fmvmul m n W x i = ∑ j : Fin n, RoleFlow.Flow.natGet W (↑i * n + ↑j) * x j
Instances For
conv1x1: per-pixel channel mixing.
Equations
- RoleFlow.Flow.fconv1x1 cin cout h w K v i = ∑ ci : Fin cin, RoleFlow.Flow.natGet K (↑i / (h * w) * cin + ↑ci) * RoleFlow.Flow.natGet v (↑ci * (h * w) + ↑i % (h * w))
Instances For
Densities of the reference measures #
The standard-normal density on Vec n.
Equations
- RoleFlow.Flow.stdNormalPDF n x = ∏ i : Fin n, ProbabilityTheory.gaussianPDFReal 0 1 (x i)
Instances For
The logistic density σ'(t) = e⁻ᵗ / (1 + e⁻ᵗ)² on Vec n: the density of a point of
(0, 1)ⁿ (uniform) in its logit chart.
Instances For
The standard normal on Vec n.
Equations
- RoleFlow.Flow.stdNormal n = MeasureTheory.volume.withDensity fun (x : RoleFlow.Flow.Vec n) => ENNReal.ofReal (RoleFlow.Flow.stdNormalPDF n x)
Instances For
The logistic distribution on Vec n.
Equations
- RoleFlow.Flow.stdLogistic n = MeasureTheory.volume.withDensity fun (x : RoleFlow.Flow.Vec n) => ENNReal.ofReal (RoleFlow.Flow.logisticPDF n x)
Instances For
From Lebesgue measure to volume.withDensity ρ by the identity, with log-weight log ρ.
Change of variables through the Jacobian #
A differentiable bijection of a finite-dimensional space with Haar measure satisfies change
of variables with |det f'|.
An invertible matrix satisfies change of variables with |det M|.
x ↦ x ⊙ exp s, with log-weight Σ s.
A translation preserves Lebesgue measure.
v ↦ v ∘ σ preserves Lebesgue measure.
The triangular channel map (Glow's LU 1 × 1 convolution) #
The matrix of triu c n on Vec (c * n), c channels of n pixels. Entry i is channel
i / n at pixel i % n. Within a pixel it is upper triangular, with diagonal exp U_aa and
entries U_ab above it (U row-major c × c).
Equations
- One or more equations did not get rendered due to their size.
Instances For
x ↦ M⁻¹ x, a triangular solve.
Equations
- RoleFlow.Flow.ftriuInv c n x U = (RoleFlow.Flow.triuMat c n U)⁻¹.mulVec x
Instances For
log det M = Σᵢ log Mᵢᵢ = n · Σ_a U_aa.
Equations
- RoleFlow.Flow.triuLogdet c n U = ∑ i : Fin (c * n), RoleFlow.Flow.natGet U (↑i / n * c + ↑i / n)
Instances For
Elementwise odd powers and their roots #
x ↦ x ^ (2k + 1) for k : ℕ (the cube at k = 1), a bijection of ℝ whose derivative
(2k + 1) x ^ 2k vanishes only at 0.
The odd exponent 2k + 1.
Equations
- RoleFlow.Flow.oddExp k = 2 * k + 1
Instances For
The real (2k + 1)-th root: x ^ (1/(2k+1)) on x ≥ 0, extended oddly.
Equations
- RoleFlow.Flow.oroot k x = if 0 ≤ x then x ^ (↑(RoleFlow.Flow.oddExp k))⁻¹ else -(-x) ^ (↑(RoleFlow.Flow.oddExp k))⁻¹
Instances For
x ↦ x ^ (2k + 1), elementwise.
Equations
- RoleFlow.Flow.fopow k v i = v i ^ RoleFlow.Flow.oddExp k
Instances For
y ↦ y ^ (1/(2k + 1)), elementwise.
Equations
- RoleFlow.Flow.foroot k v i = RoleFlow.Flow.oroot k (v i)
Instances For
Σᵢ log ((2k + 1) xᵢ ^ 2k) off the axes: the log-determinant of the elementwise power.
Equations
- RoleFlow.Flow.opowLogdet k v = ∑ i : Fin n, Real.log (RoleFlow.Flow.opowDet1 k (v i))
Instances For
x ↦ x ^ (2k + 1), with log-weight opowLogdet k.