rnn_cell

std.nn.rnn_cell · Level L0

One step of an Elman recurrent network: the next hidden state from the current one and an input. The body that rnn scans.

h′ = tanh(W·h + U·x + b)

Signature

rnn_cell(h: f64[k], x: f64[m], W: f64[k, k], U: f64[k, m], b: f64[k]) → f64[k]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

hf64[k]Wf64[k, k]xf64[m]Uf64[k, m]bf64[k]ReshapehcReshapexcMatMulWhMatMulUxAddpre_cReshapepreAddzTanhh2h2f64[k]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference np.tanh(W @ h + U @ x + b) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 140 float64 results inside the running error bound; the closest uses 18% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
78%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
6.74

Identity

Calls
—
Called by
sha256:9a700122c77baec1c1c1277c658bd5b0ca5bfa54458f876385416330f4a0fc2d

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