The trained models, as programs of the flow signature #
The models of SemiInv2, with the same stages, weights and inits. A stage is written with a builder (B): an operation applied to
positions returns the positions of its results, so a stage is a function from the positions
of its weights and inputs to the positions it returns. Sorts are compared by value when the
program is checked (Prog.WF), so the builder needs no typing of its own.
A model is a list of stages over one weight context, the stages' weights side by side
(Stage.at). Its program (modelProg) runs the stages' bodies one after another in one
builder, each on what the previous one passes on, and is typed by inference as a whole; or
(callProg) it calls each stage, defined on its own weights in a tower of definitions
(Linked). A stage may factor out its first fac outputs: they are returned by the model, and
in stageProgs every later stage takes them as extra (unused) weights. Nothing here is trusted:
the printer (RoleFlow.Flow.Print) checks what it prints.
The builder #
A builder of lines of Sg.
Equations
- RoleFlow.Flow.BG Sg = StateM (RoleFlow.Flow.BSt Sg)
Instances For
A builder of lines of the flow signature.
Instances For
ys = o(xs) for an operation of the flow signature.
Equations
- RoleFlow.Flow.B.op o xs = RoleFlow.Flow.B.line o xs
Instances For
An actnorm on vec n: x ↦ x ⊙ exp s + b.
Equations
- RoleFlow.Flow.B.actnorm n x s b = do let __do_lift ← RoleFlow.Flow.B.o2 (RoleFlow.Flow.FOp.scaleexp n) x s RoleFlow.Flow.B.o2 (RoleFlow.Flow.FOp.add n) __do_lift b
Instances For
Equations
- RoleFlow.Flow.small n = toString "small:" ++ toString n
Instances For
Equations
- RoleFlow.Flow.zero n = toString "zero:" ++ toString n
Instances For
A stage: its weights with their inits, inputs and outputs, and its body from the positions
of the weights and the inputs to the returned positions. The first fac outputs are factored
out.
Instances For
A model's weights: the stages' weights side by side.
Equations
- RoleFlow.Flow.modelWts stages = (List.map (fun (x : RoleFlow.Flow.Stage) => List.map (fun (x : RoleFlow.Flow.FS × String) => x.1) x.wts) stages).flatten
Instances For
The stages of a model as programs over the model's weights: each with the weights
Θ ++ C, C what the earlier stages factored out, and with that C.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A model as one program, each stage run by run (from the positions of its weights and
inputs) in one builder, on the outputs the previous stage does not factor out. It returns the
factored-out outputs, then the rest of the last stage's.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A model as one program: the stages' bodies one after another.
Equations
- RoleFlow.Flow.modelProg stages = RoleFlow.Flow.modelProgOf (fun (x : RoleFlow.Flow.Stage) => x.body) stages
Instances For
A model as one program of calls: each stage a call of the definition of its name in L
(Linked.find), on its inputs, then its weights.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stages shared by the models #
score n: the last stage, so that the forward log-weight is the log-density.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Data in (0, 1)ⁿ, given in its logit chart, as a vector.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Two dimensions #
An affine coupling on vec (m + m), after an actnorm: x₂ ↦ x₂ ⊙ exp (tanh s) + t with
(s, t) an MLP of x₁ with two hidden layers. The output is (x₂', x₁).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A learned invertible linear map on vec (m + m) in block-LU form: a diagonal scale
exp logS, then the shears a ↦ a + U b and b ↦ b + L a.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Augmentation: the data x : vec n and a hidden standard-normal input u : gauss k, which
sample turns into data and which is appended to x.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A flow on the plane: toyN on the data augmented by 2 * augPairs hidden dimensions.
Equations
Instances For
Permutations of images #
Permutations as steps (PermS): σ.trans τ (first σ) is τ ++ σ, since a gather reads
τ's index through σ's.
Squeezing cin channels of (s f) × (s f) by f, then a rotation of the flat vector by
shift. Output channel chan c', with c' = ci * f² + f dy + dx, at (r, q) reads channel
ci at (f r + dy, f q + dx).
Equations
- One or more equations did not get rendered due to their size.
Instances For
squeezeC with one input channel.
Equations
- RoleFlow.Flow.squeeze f s chan shift = RoleFlow.Flow.squeezeC 1 f s chan shift
Instances For
Reordering a × b channels as b × a.
Instances For
A channel permutation of the channels of n pixels each: output channel a reads input
channel π a.
Equations
- RoleFlow.Flow.chanPerm n π = List.map (RoleFlow.Flow.PermStep.embed 1 n) π
Instances For
The rotation of k channels by s: channel a reads a + s.
Equations
- RoleFlow.Flow.chanRot k s = [RoleFlow.Flow.PermStep.roll [k] 0 ((k - s % k) % k)]
Instances For
MNIST #
The coupling network of a Glow coupling on c channels of h × w (hid wide), reading
a and the weights at w i₀, …: a 3 × 3 conv, relu, a 1 × 1 conv, relu, a 3 × 3 conv to
(s, t).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The deeper coupling network of glowResAt: u₁ = relu (conv₃ₓ₃ a), two residual layers
uᵢ₊₁ = uᵢ + conv₃ₓ₃ (relu (conv₁ₓ₁ (relu uᵢ))), then (s, t) = conv₃ₓ₃ (relu u₃).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A Glow block at any resolution, after an actnorm: c + c channels of h × w, permuted by
sq; the halves are coupled in turn (b' = b ⊙ exp sA(a) + tA(a), then
a' = a ⊙ exp sB(b') + tB(b')), and sq⁻¹ restores the layout. net is the coupling network
and netW its weights.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Factoring out half of the dimensions, with Glow's learned prior: after sq, the first half
x₁ passes on, and the second is scored under N (μ, σ²) with (μ, log σ) a conv net of
x₁. The scored half is factored out, so it comes first: the stage returns (z, x₁).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The multiscale coupling flow for MNIST with fixed permutations (mnistCoupling of
semiInv): logit 784, fine blocks on 4 × 14 × 14, splitPrior, coarse residual
blocks on 8 × 7 × 7, score 392.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Glow #
One step of Glow on c + c channels of h × w, in the image layout (squeezed by sq and
back): an actnorm, the invertible 1 × 1 convolution W = P L U (U, L by triu, L
between two channel reversals, P the channel permutation π), and one affine coupling.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Glow for MNIST, in two levels: logit 784, fine steps on 4 × 14 × 14, splitPrior,
coarse steps on 8 × 7 × 7, score 392.
Equations
- One or more equations did not get rendered due to their size.
Instances For
TARFlow on image patches #
The weights of tarflowBlock: the token embedding, one position embedding per token, the
layers, the head to (α, μ), and (α₁, μ₁) for the first token.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One TARFlow block on T ≥ 1 tokens of dimension d, in the token layout given by σ:
zₙ = (xₙ − μₙ) ⊙ exp (−tanh αₙ), with (αₙ, μₙ) read off a causal transformer (width h,
L pre-norm layers of single-head attention and a GELU MLP, a key-value cache per layer) at
token n − 1, and learned (α₁, μ₁). σ⁻¹ restores the layout.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The image s f × s f cut into s × s patches of f × f, patch-major.
Equations
- RoleFlow.Flow.patchify f s = RoleFlow.Flow.squeeze f s [] 0 ++ RoleFlow.Flow.chanSwap (s * s) (f * f)
Instances For
The token order reversed (T tokens of d).
Equations
Instances For
TARFlow for Fashion-MNIST: logit 784, then blocks TARFlow blocks on the (28 / p)²
patches of p × p pixels, then score 784. Odd blocks reverse the token order; blocks 2, 3
(mod 4) roll the image by p / 2 pixels first.
Equations
- One or more equations did not get rendered due to their size.