TorchLean API

NN.MLTheory.Proofs.ReLU.Approx.ReLUMulApprox

Approximating multiplication with a 2-layer ReLU MLP (2D box) #

This file gives a constructive, fully proved approximation result: on $[-M,M]^2$, the function $(x_0,x_1)\mapsto x_0x_1$ can be uniformly approximated by a single-hidden-layer ReLU MLP on Tensor ℝ [2].

First coordinate projection from a rank-one tensor with two entries.

Instances For

    Second coordinate projection from a rank-one tensor with two entries.

    Instances For

      The closed box domain $[-M,M]\times[-M,M]$.

      Instances For

        The target multiplication map: multiply the two coordinates.

        Instances For

          Ridge direction with dot wPlus x equal to the sum of the two coordinates.

          Instances For

            Ridge direction with dot wMinus x equal to the first coordinate minus the second.

            Instances For

              Evaluate the ridge wMinus: $\operatorname{dot}(w_-,x)=x_0-x_1$.

              theorem NN.MLTheory.Proofs.ReLUMulApprox.mul_identity (x y : ) :
              x * y = ((x + y) * (x + y) - (x - y) * (x - y)) / 4

              Algebraic identity expressing multiplication via a difference of squares.

              Unpack the defining bounds of membership in box M.

              If $x\in\operatorname{box}(M)$, then $x_0+x_1\in[-2M,2M]$.

              If $x\in\operatorname{box}(M)$, then $x_0-x_1\in[-2M,2M]$.

              theorem NN.MLTheory.Proofs.ReLUMulApprox.square_lipschitz_Icc {R : } (_hR : 0 R) (x : ) :
              x Set.Icc (-R) RySet.Icc (-R) R, |x * x - y * y| 2 * R * |x - y|

              Lipschitz bound for square on $[-R,R]$: $|x^2-y^2|\leq 2R|x-y|$.

              Concatenate tensors along the leading dimension.

              In this file, this is used to append the hidden-unit vectors of two subnetworks.

              Instances For
                noncomputable def NN.MLTheory.Proofs.ReLUMulApprox.appendLinearSpec {inDim m n : } (a : Spec.LinearSpec inDim m) (b : Spec.LinearSpec inDim n) :
                Spec.LinearSpec inDim (m + n)

                Append two first-layer linear specs by appending their weight and bias tensors.

                Instances For
                  noncomputable def NN.MLTheory.Proofs.ReLUMulApprox.mat1Get {n : } (A : TorchLean.Tensor [1, n]) (j : Fin n) :

                  Extract the j-th entry from a 1 × n tensor interpreted as a row matrix.

                  Instances For

                    mat1Get agrees with the Tensor.matrix constructor.

                    noncomputable def NN.MLTheory.Proofs.ReLUMulApprox.combineOutput {m n : } (α β γ : ) (a : Spec.LinearSpec m 1) (b : Spec.LinearSpec n 1) :

                    Combine two scalar-output linear specs into one scalar-output spec on an appended hidden layer.

                    If the appended hidden vector is $[z_a;z_b]$, the resulting output layer computes $\gamma+\alpha\,\mathrm{out}_a(z_a)+\beta\,\mathrm{out}_b(z_b)$.

                    Instances For

                      Reading the left component from an appended hidden vector.

                      Reading the right component from an appended hidden vector.

                      Pointwise behavior of the ReLU activation on tensor-vectors.

                      Matrix-vector multiplication for a 1 × n matrix produces a single scalar coordinate.

                      Expand mlp_eval_nd into “bias + sum over hidden units” form.

                      This is the main normalization lemma used to prove that appendLinearSpec together with combineOutput implements affine combinations of subnetworks.

                      Selecting the left block of a linear spec appended via appendLinearSpec.

                      Selecting the right block of a linear spec appended via appendLinearSpec.

                      theorem NN.MLTheory.Proofs.ReLUMulApprox.mlp_eval_append_linear {inDim m n : } (l1a : Spec.LinearSpec inDim m) (l1b : Spec.LinearSpec inDim n) (l2a : Spec.LinearSpec m 1) (l2b : Spec.LinearSpec n 1) (α β γ : ) (x : TorchLean.Tensor [inDim]) :
                      ReLUMlpBridge.mlpEval (appendLinearSpec l1a l1b) (combineOutput α β γ l2a l2b) x = γ + α * ReLUMlpBridge.mlpEval l1a l2a x + β * ReLUMlpBridge.mlpEval l1b l2b x

                      Appending hidden units and wiring the output with combineOutput yields an affine combination.

                      Concretely, the combined network computes: $\gamma+\alpha\,\mathrm{net}_a(x)+\beta\,\mathrm{net}_b(x)$.

                      theorem NN.MLTheory.Proofs.ReLUMulApprox.relu_mul_universal_approximation_box {M : } (hM : 0 < M) (ε : ) :
                      ε > 0∃ (hidDim : ) (l1 : Spec.LinearSpec 2 hidDim) (l2 : Spec.LinearSpec hidDim 1), xbox M, |mulFun x - ReLUMlpBridge.mlpEval l1 l2 x| < ε

                      Uniform approximation of multiplication on $[-M,M]^2$ by a single-hidden-layer ReLU MLP.

                      The construction follows the classical reduction $xy=((x+y)^2-(x-y)^2)/4$, combined with a one-dimensional ReLU approximator for square on $[-2M,2M]$ that is lifted along the ridge directions wPlus and wMinus.