Mlp #
CROWN/DeepPoly-style propagation for MLPs (vector in/out) using TorchLean tensors.
This file is a compact implementation that sits on top of:
NN.MLTheory.CROWN.Core(Box,AffineVec, andIBP.linear), and- TorchLean’s typed tensor layer (
TorchLean.Tensor).
What is implemented:
- Per-neuron ReLU linear relaxations derived from pre-activation bounds using the canonical
Runtime.Ops.ReLU.relaxScalarandRuntime.Ops.ReLU.relaxScalarLowerdefinitions. - The IBP forward rule for ReLU; other activations use
Runtime.Ops.IBPdirectly. - A two-layer ReLU MLP wrapper
TwoLayerMLPwith a simple end-to-end bounding API.
Scope boundaries in this MLP-focused module:
- General computation graphs. Use
NN.MLTheory.CROWN.Graphfor the graph-level certificate checker andNN.MLTheory.CROWN.Proofs.GraphCrownCertSoundnessfor the corresponding end-to-end soundness theorem. - Objective-dependent / backward CROWN slope optimization. The
certificate infrastructure for alpha-CROWN, with and without ReLU phases, lives under
NN.MLTheory.CROWN.Cert.AlphaCROWNandNN.MLTheory.CROWN.Cert.PhasedCROWN.
References:
- CROWN: Zhang et al., "Efficient Neural Network Robustness Certification with General Activation Functions", arXiv:1811.00866.
- auto_LiRPA: Xu et al., "Automatic Perturbation Analysis for Scalable Certified Robustness and Beyond", NeurIPS 2020, arXiv:2002.12920.
PyTorch analogues:
torch.nn.Linear: https://pytorch.org/docs/stable/generated/torch.nn.Linear.htmltorch.nn.ReLU: https://pytorch.org/docs/stable/generated/torch.nn.ReLU.html
Column-wise scaling of a matrix by a vector: scale each column j by v[j].
Instances For
Extract the slope vector from a tensor of ReLU relaxations.
Instances For
Extract the bias vector from a tensor of ReLU relaxations.
Instances For
Interval Bound Propagation (IBP) for the vector-shaped ReLU used by TwoLayerMLP.
This is an executable transfer function. Its soundness theorem instantiates the scalar type with
ℝ.
The linear-layer bound helper IBP.linear lives in NN.MLTheory.CROWN.Core.
Interval bounds for ReLU on a vector.
This is the standard elementwise interval evaluation:
relu([l,u]) = [relu(l), relu(u)].
Instances For
Two-layer MLP payload used by this file.
Semantics: y = outputWeight * relu(hiddenWeight * x + hiddenBias) + outputBias.
PyTorch analogue: torch.nn.Sequential(Linear(inDim,hidDim), ReLU(), Linear(hidDim,outDim)).
- outputWeight : TorchLean.Tensor α [outDim, hidDim]
Second layer weight matrix.
- outputBias : TorchLean.Tensor α [outDim]
Second layer bias vector.
Instances For
Forward semantics for TwoLayerMLP (used to state soundness theorems).
Instances For
Compute an output interval box via pure IBP.
This is fast and, when BoundOps α supplies sound outward endpoint operations, typically looser
than CROWN/DeepPoly affine bounds.
Instances For
The lower and upper affine CROWN forms for this two-layer ReLU MLP.
The returned pair is (lower, upper). boundAffineCrown evaluates these forms on the input box and
takes the lower and upper endpoints. Exact backends use the two-layer algebraic formula.
Rounded backends share the graph engine's directed coefficient propagation, which has no
coefficient transfer for ReLU: the hidden layer is consumed through its IBP box, so the input
coefficients are zero and the result is the IBP bound of the output layer. No theorem covers the
rounded branch.
Instances For
Affine (CROWN/DeepPoly-style) bounds for the 2-layer ReLU MLP.
Rounded scalar backends use the same directed arithmetic as the general graph CROWN API.
Instances For
Theorems inspired by CROWN (Zhang et al., 2018, arXiv:1811.00866)
We record soundness properties of the relaxations and bound propagation. Proofs below require elementary order reasoning and case splits on signs, plus properties of mat-vec interval arithmetic.
Vectorized ReLU relaxation (pointwise upper bound) over ℝ.
If x ∈ [lo, hi] and rp := ReLU.relaxScalar loᵢ hiᵢ, then for every component i we have
relu(xᵢ) ≤ rpᵢ.slope * xᵢ + rpᵢ.bias.
Soundness of IBP.linear over ℝ.
If x ∈ xB and b ∈ bB, then W*x + b lies in the interval box computed by
IBP.linear W xB bB.
Soundness of pure IBP bounds for a 2-layer MLP over ℝ.