Our integration via trapezoidal rule is bad because
a. Cleverer methods exist
b. Especially for smooth-ish functions much better methods exist
c. We want to switch between alpha=1 ("gradient") and integration
This PR
Refactors integration to use "weights" which replaces the old trapezoidal_scaler and interval_size. The integration result is now given by integral(f) = sum(weights*f(samples)), in practice this just replaces the trapezoidal_scaler and interval_size terms with weights
Implements three functions generating "weights" and "alphas": Trapezoidal, Gradient, Gauss-Legendre. Gauss-Legendre is only one of those clever methods (though one of the best & simplest ones) but one could easily add more. This is controlled via the integration_rule config value.
Renamed integrated_gradient_trapezoidal_norm to calc_basis_integrated_gradient,
Implemented tests for
Test calc_basis_integrated_gradient in both integration formulas on a polynomial
Test on a more complex function
Test on a 1/sqrt(x) function, inspired by LN
Test functions that define the integration steps and weights
Build graph with new integral rule (but no comparisons against old graphs)
Note: Branched of from stochastic sources branch!
Our integration via trapezoidal rule is bad because a. Cleverer methods exist b. Especially for smooth-ish functions much better methods exist c. We want to switch between alpha=1 ("gradient") and integration
This PR
integration_rule
config value.integrated_gradient_trapezoidal_norm
tocalc_basis_integrated_gradient,
Implemented tests for
calc_basis_integrated_gradient
in both integration formulas on a polynomial