Package deepboof.backward
Interface NumericalGradient<T extends deepboof.Tensor<T>>
- All Known Implementing Classes:
NumericalGradient_F64
public interface NumericalGradient<T extends deepboof.Tensor<T>>
Given a Function implementations of this interface will compute the gradient of its
inputs and parameters. Numerical differentiation is done using a symmetric sample, e.g.
dx = [f(x+T)-f(x-T)]/T
-
Method Summary
Modifier and Type Method Description voidconfigure(double T)Overrides default settings for computing numerical gradient.voiddifferentiate(T input, List<T> parameters, T dout, T gradientInput, List<T> gradientParameters)Performs numerical differentiation to compute the gradients of input and parameters.voidsetFunction(deepboof.Function<T> function)Sets the function which will be differentiated and other parameters.
-
Method Details
-
configure
void configure(double T)Overrides default settings for computing numerical gradient.- Parameters:
T- Sampling distance used for numerical differentiation
-
setFunction
Sets the function which will be differentiated and other parameters.Function.initialize(int...)should have already been called.- Parameters:
function- The function which is to be differentiated
-
differentiate
void differentiate(T input, List<T> parameters, T dout, T gradientInput, List<T> gradientParameters)Performs numerical differentiation to compute the gradients of input and parameters. When numerical differentiation is being performedinputandparameterswill be modified and then returned to their original state.- Parameters:
input- The same input tensor which was passed in during the forward pass.parameters- The same parameters which was passed in during the forward pass.dout- Derivative of output, computed from next layer.gradientInput- Storage for gradient of inputgradientParameters- Storage for gradients of parameters
-