Expand description
Extended numeric stability toolkit (gradients, error helpers, array-based activations)
§Numeric Stability Toolkit
Extended numeric stability utilities that complement the core stability module.
This module provides:
- Error helpers:
relative_error,absolute_error - Compensated summation: convenience wrapper around Kahan accumulation
- Stable activations:
softmax_array,sigmoid_array(ndarray-based) - Condition estimation:
condition_number_1dfor 1-D ratio analysis - Numerical differentiation:
numerical_gradientwith forward/backward/central modes - Gradient checking:
check_gradientto compare analytical vs numerical gradients
Structs§
- Gradient
Check Result - Result of a gradient check.
Enums§
- Difference
Mode - Mode of finite difference approximation.
Functions§
- absolute_
error - Absolute error between two values: |a - b|.
- check_
gradient - Check an analytical gradient against a numerical gradient.
- compensated_
sum - Compute a compensated (Kahan) sum of a slice.
- compensated_
sum_ array - Compute a compensated (Neumaier) sum of an ndarray view.
- condition_
number_ 1d - Estimate a “condition number” for a 1-D array as max(|x|) / min_nonzero(|x|).
- log_
sum_ exp_ array - Numerically stable log-sum-exp for an ndarray 1-D array.
- max_
relative_ error - Maximum relative error across all elements.
- numerical_
gradient - Compute the numerical gradient of a scalar function at point
x. - pairwise_
sum_ array - Pairwise summation for an ndarray view.
- relative_
error - Relative error between
computedandreference: |computed - reference| / |reference|. - relative_
errors - Element-wise relative errors between two arrays.
Returns
Errif the arrays have different lengths. - sigmoid_
array - Numerically stable sigmoid for an ndarray 1-D array.
- softmax_
array - Numerically stable softmax for an ndarray 1-D array.