TorchLean API

NN.MLTheory.Proofs.ReLU.Bridge.ReLUMlpBridge

Bridging Scalar ReLU MLPs to Tensor Inputs #

This file is a first “bridge step” between:

What is proved here (fully proved):

  1. Exact representability of affine maps $x\mapsto w\mathbin{\cdot}x+b$ by a two-layer ReLU MLP of width $2$, using $\operatorname{ReLU}(u)-\operatorname{ReLU}(-u)=u$.
  2. Ridge lifting: any scalar-input 2-layer ReLU MLP can be lifted to a tensor input via $u=w\mathbin{\cdot}x+c$, by scaling each first-layer weight by $w$ and adjusting biases accordingly.

The multivariate compact-set approximation theorem itself is proved downstream in NN.MLTheory.Proofs.ReLU.Approximation.CompactSet, using these bridge lemmas together with Stone–Weierstrass.

noncomputable def NN.MLTheory.Proofs.ReLUMlpBridge.dot {n : ℕ} (w : Fin n → ℝ) (x : TorchLean.Tensor ℝ [n]) :

Dot product $w\mathbin{\cdot}x$ for coordinate weights w and a rank-one tensor x.

Instances For
    noncomputable def NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval {n hidDim : ℕ} (l1 : Spec.LinearSpec ℝ n hidDim) (l2 : Spec.LinearSpec ℝ hidDim 1) (x : TorchLean.Tensor ℝ [n]) :

    Evaluate a single-hidden-layer ReLU MLP on a tensor input and return the scalar output.

    Instances For

      The identity $\operatorname{ReLU}(u)-\operatorname{ReLU}(-u)=u$, used to represent affine maps exactly with ReLU.

      Extract the unique entry from row i of an (m×1) tensor interpreted as a matrix.

      Instances For
        noncomputable def NN.MLTheory.Proofs.ReLUMlpBridge.affineIdLayer1 {n : ℕ} (w : Fin n → ℝ) (b : ℝ) :

        First layer for exact affine representability.

        Given an affine form $u(x)=w\mathbin{\cdot}x+b$, this layer outputs $[u(x),-u(x)]$.

        Instances For

          Second layer for exact affine representability.

          With hidden activations $[\operatorname{ReLU}(u),\operatorname{ReLU}(-u)]$, this output layer computes $\operatorname{ReLU}(u)-\operatorname{ReLU}(-u)=u$.

          Instances For
            noncomputable def NN.MLTheory.Proofs.ReLUMlpBridge.stdBasis {n : ℕ} (i : Fin n) :
            Fin n → ℝ

            Standard basis vector $e_i\in\mathbb{R}^n$.

            Instances For

              $\operatorname{dot}(e_i,x)=x_i$ for the standard basis stdBasis.

              Exact representability of affine maps by a 2-layer ReLU MLP (width 2).

              This is the core bridge lemma that turns scalar affine forms $w\mathbin{\cdot}x+b$ into MLP evaluations.

              Exact representability of coordinate projections $x\mapsto x_i$ by a width-$2$ ReLU MLP.

              Ridge lifting #

              Given a scalar-input MLP (l1,l2) and an affine scalar map $u=w\mathbin{\cdot}x+c$, we build a tensor-input MLP whose pre-activations match the scalar-input pre-activations at $u$. This lets you reuse any scalar approximation result for functions of one affine form (“ridge functions”).

              noncomputable def NN.MLTheory.Proofs.ReLUMlpBridge.liftScalarLayer1 {n hidDim : ℕ} (l1 : Spec.LinearSpec ℝ 1 hidDim) (w : Fin n → ℝ) (c : ℝ) :

              Lift a scalar-input first layer to a tensor-input first layer along a ridge direction.

              Given a first layer that expects a scalar $u\in\mathbb{R}$, this constructs a tensor-input layer that feeds it $u=w\mathbin{\cdot}x+c$.

              Instances For
                theorem NN.MLTheory.Proofs.ReLUMlpBridge.mlp_eval_lift_from_scalar {n hidDim : ℕ} (l1 : Spec.LinearSpec ℝ 1 hidDim) (l2 : Spec.LinearSpec ℝ hidDim 1) (w : Fin n → ℝ) (c : ℝ) (x : TorchLean.Tensor ℝ [n]) :

                Lifting lemma: the lifted tensor-input MLP agrees with the scalar-input MLP evaluated at $w\mathbin{\cdot}x+c$.