mlp2

std.nn.mlp2 · Level L0

Two-layer perceptron with a ReLU between the layers. Calls linear twice.

Y = relu(X·W₁ + b₁)·W₂ + b₂

Signature

mlp2(X: f64[m, k], W1: f64[k, h], b1: f64[h], W2: f64[h, n], b2: f64[n]) → f64[m, n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks a call to another library function; select it to open that function.

Xf64[m, k]W1f64[k, h]b1f64[h]W2f64[h, n]b2f64[n]linearHReluRlinearYYf64[m, n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference np.maximum(X @ W1 + b1, 0) @ W2 + b2 in exact rational arithmetic, on all 40 test cases.
  • All 623 float64 results inside the running error bound; the closest uses 62% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
71%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
64

Large ulp counts appear only where cancellation drives a result toward zero; the absolute error is still inside the bound.

Identity

Calls
Called by
—
sha256:15c1dbbe0e89904fbf01f9439cc4045edc9ee449d2168d26f56adadd1e0f4f7b

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.