evalNetwork
Evaluation of a feedforward ReLU neural network of hidden layer width $k$ on a real input $x$, which forms an initial width-$k$ vector by applying input weights and biases to $x$, iteratively updates the vector through each hidden layer using evalHiddenLayer, and computes the final scalar by taking the inner product with output weights and adding the output bias.
Statement
def evalNetwork {k : ℕ} (net : ReLUNetwork k) (x : ℝ) : ℝ- Defined in
- arXiv:2610.06092 Section 2.1
- Verified
- 25 Oct 2026
- Axioms
- none listed
- Built on 3
- ReLUNetworkA feedforward ReLU neural network from the real line to the real line with hidden layers of width k, specified by rational affine input…
- evalHiddenLayerEvaluation of a hidden layer of width $k$ on an input vector $x \in \mathbb{R}^k$, computing for each neuron $i$ the rectified linear unit…
- ReLUHiddenLayerA hidden layer of width k consists of a k-by-k rational weight matrix and a rational bias vector of length k.
- Used by 7
- op75_compact_network_subset_sumFor any finite list of nonnegative integer weights and nonnegative integer target, the explicitly constructed width-three ReLU network has…
- relu_network_zero_of_ivtIf a feedforward ReLU neural network of width $k$ evaluates to a non-positive value at 0 and a non-negative value at 1, then by the…
- op75_network_evalFor a unit-interval input, the explicit subset-sum network evaluates to the final orbit coordinate plus the absolute difference between…
- relu_network_width4_liftingWidth-4 lifting theorem (Theorem 5.8 of arXiv:2610.06092): For every 3-CNF formula $f$ with variable indices in $\mathbb{N}$, there exists…
- relu_network_has_unit_interval_zeroA feedforward ReLU neural network
netof width $k$ has a zero in the unit interval $[0, 1]$ if there exists some real number… - relu_network_eval_continuousFor every natural number $k$ and every feedforward ReLU neural network
netof width $k$ with rational weights and biases, the evaluation… - op_75_relu_width3_liftingOpen Problem OP-75 (arXiv:2610.06092, Remark 5.15): For every 3-CNF formula $f$ with variable indices in $\mathbb{N}$, there exists a…
Read back from the Lean
A definition of evalNetwork, which evaluates a feedforward neural network net : ReLUNetwork k (with rational weights and biases coerced to ℝ, and uniform layer width k : ℕ) on a single real input x : ℝ to produce a real output ℝ.
The evaluation consists of:
1. Computing an initial vector x0 : Fin k → ℝ by an affine map from x: for each i : Fin k, x0 i = (net.in_weight i : ℝ) * x + (net.in_bias i : ℝ).
2. Iteratively passing the vector through each hidden layer in the list net.layers from left to right (via foldl). Each layer l : ReLUHiddenLayer k maps a vector v : Fin k → ℝ to a new vector whose i-th component is max ((∑ j : Fin k, (l.weight i j : ℝ) * v j) + (l.bias i : ℝ)) 0.
3. Computing the scalar output by an affine combination of the final hidden state x_hidden : Fin k → ℝ: (∑ i : Fin k, (net.out_weight i : ℝ) * x_hidden i) + (net.out_bias : ℝ).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- Evaluate a feedforward ReLU neural network on a real input. -/ def evalNetwork {k : ℕ} (net : ReLUNetwork k) (x : ℝ) : ℝ := let x0 : Fin k → ℝ := fun i => (net.in_weight i : ℝ) * x + (net.in_bias i : ℝ) let x_hidden := net.layers.foldl (fun v l => evalHiddenLayer l v) x0 (∑ i, (net.out_weight i : ℝ) * x_hidden i) + (net.out_bias : ℝ)