Class BlackBoxGradient
- java.lang.Object
-
- ai.libs.jaicore.math.gradientdescent.BlackBoxGradient
-
- All Implemented Interfaces:
IGradientFunction
public class BlackBoxGradient extends java.lang.Object implements IGradientFunction
Difference quotient based gradient estimation. This class will give a black-box gradient estimation by simply calculating (f(x + h) - f(x))/h where x is the provided point and x' is a point that slightly differs, specified by the parameterprecision. (Obviously it holds that in lim_{precision -> 0} this yields the exact gradient.) If x is a vector (a_o, ..., a_n), then, instead we calculate each partial derivative i by: (f(a_o, ... a_i +h, ... , a_n) - f((a_o, ..., a_n)))/h Obviously, this is a highly inefficient approach for estimating the gradient (if we have n partial derivatives, we need 2 *n estimations).
-
-
Constructor Summary
Constructors Constructor Description BlackBoxGradient(IGradientDescendableFunction underlyingFunction, double precision)Sets up a gradient-estimator for the given function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.api4.java.common.math.IVectorapply(org.api4.java.common.math.IVector xVec)Returns the result of applying the gradient to the point represented by the given vector.
-
-
-
Constructor Detail
-
BlackBoxGradient
public BlackBoxGradient(IGradientDescendableFunction underlyingFunction, double precision)
Sets up a gradient-estimator for the given function. The estimation of the gradient can be tuned by the precision parameter.- Parameters:
underlyingFunction- the function for which the gradient shall be estimatedprecision- the precision of the estimation, the close this value is to zero the better is the estimation
-
-
Method Detail
-
apply
public org.api4.java.common.math.IVector apply(org.api4.java.common.math.IVector xVec)
Description copied from interface:IGradientFunctionReturns the result of applying the gradient to the point represented by the given vector.- Specified by:
applyin interfaceIGradientFunction- Parameters:
xVec- the vector the gradient is applied to- Returns:
- the new vector resulting from applying the gradient to the given vector
-
-