gelu_tanh
std.elementwise.gelu_tanh · Level L0GELU, tanh approximation, as used in GPT-style networks.
½·x·(1 + tanh(c·(x + 0.044715·x³))), c = √(2/π)
Signature
gelu_tanh(x: f64[n]) → f64[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.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Agrees with the reference
0.5 * x * (1 + np.tanh(c * (x + 0.044715 * x**3)))to 80 digits (100-digit arithmetic), on all 40 test cases. - All 162 float64 results inside the running error bound; the closest uses 48% of it.
- Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
- correctly rounded (the float64 nearest the exact value)
- 65%
- bit-equal to the NumPy formula in float64
- 100%
- largest error, in units in the last place
- 8.3e+15
Large ulp counts appear only where cancellation drives a result toward zero; the absolute error is still inside the bound.
Note
c is the float64 value nearest √(2/π); the reference uses the same constant.
Identity
sha256:3c2cdf2da16959ecd913253994d8a490b2710d09d69fa1ddb6becf33158f1573The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.