Checks
If you have computed a gradient or differential and you are not sure whether it is correct.
Manopt.check_differential
— Functioncheck_differential(M, F, dF, p=random_point(M), X=random_tangent(M,p))
Check numerivcally whether the differential dF(M,p,X)
of F(M,p)
is correct.
This implements the method described in Section 4.8 [Boumal2022].
Keyword arguments
N
(101
) – number of points to check within thelog_range
default range $[10^{-8},10^{0}]$throw_error
- (false
) throw an error message if the gradient is wrongio
– (nothing
) provide anIO
to print the check result tolimits
((1e-8,1)
) specify the limits in thelog_range
log_range
(range(limits[1], limits[2]; length=N)
) - specify the range of points (in log scale) to sample the gradient lineplot
- (false
) whether to plot the resulting check (ifPlots.jl
is loaded). The plot is in log-log-scale.retraction_method
- (default_retraction_method(M)
) retraction method to use for the checkslope_tol
– (0.1
) tolerance for the slope (global) of the approximation
Manopt.check_gradient
— Functioncheck_gradient(M, F, gradF, p=random_point(M), X=random_tangent(M,p); kwargs...)
Check numerivcally whether the gradient gradF(M,p)
of F(M,p)
is correct.
This implements the method described in Section 4.8 [Boumal2022].
Its keyword arguments are the same as for the check_differential
and Additionally
check_vector
_ (true
) whether or not to check that the gradient is a tangent vector.
Manopt.find_best_slope_window
— Function(a,b,i,j) = find_best_slope_window(X,Y,window=nothing; slope=2.0, slope_tol=0.1)
Check data X,Y for the largest contiguous interval (window) with a regression line fitting “best”. Among all intervals with a slope within slope_tol
to slope
the longest one is taken. If no such interval exists, the one with the slope closest to slope
is taken.
If the window is set to nothing
(default), all window sizes 2,...,length(X)
are checked. You can also specify a window size or an array of window sizes.
For each window size , all its translates in the data are checked. For all these (shifted) windows the regression line is computed (i.e. a,b
in a + t*b
) and the best line is computed.
From the best line the following data is returned
a
,b
specifying the regression linea + t*b
i
,j
determining the window, i.e the regression line stems from dataX[i], ..., X[j]
Internal methods
- Boumal2022
Boumal, N.: An Introduction to Optimization on Smooth Manifolds, book in preparation, 2022. url: http://www.nicolasboumal.net/book.