pyproximal.utils.gradtest.gradtest_bilinear#
- pyproximal.utils.gradtest.gradtest_bilinear(Op, delta=1e-06, rtol=1e-06, atol=1e-21, complexflag=False, raiseerror=True, verb=False, backend='numpy')[source]#
Gradient test for Bilinear operator.
Compute the gradient of
Op
using both the provided method and a numerical approximation with a perturbationdelta
applied to a single, randomly selected parameter of either thex
ory
vectors.- Parameters
- Op
pyproximal.utils.BilinearOperator
Bilinear operator to test.
- delta
float
, optional Perturbation
- rtol
float
, optional Relative gradtest tolerance
- atol
float
, optional Absolute gradtest tolerance
- complexflag
bool
, optional Generate random vectors with real (
False
) or complex (True
) entries- raiseerror
bool
, optional Raise error or simply return
False
when dottest fails- verb
bool
, optional Verbosity
- backend
str
, optional Backend used for dot test computations (
numpy
orcupy
). This parameter will be used to choose how to create the random vectors.
- Op
- Returns
- passed
bool
Passed flag.
- passed
- Raises
- AssertionError
If grad-test is not verified within chosen tolerances.
Notes
A gradient-test is mathematical tool used in the development of numerical bilinear operators.
More specifically, a correct implementation of the gradient for a bilinear operator should verify the following equalities within a numerical tolerance:
\[\frac{\partial Op(\mathbf{x})}{\partial \mathbf{x}} = \frac{Op(\mathbf{x}+\delta \mathbf{x}, \mathbf{y})- Op(\mathbf{x})}{\delta \mathbf{x}, \mathbf{y}}\]and
\[\frac{\partial Op(\mathbf{x}, \mathbf{y})}{\partial \mathbf{y}} = \frac{Op(\mathbf{x}, \mathbf{y}+\delta \mathbf{y})- Op(\mathbf{x}, \mathbf{y})}{\delta \mathbf{y}}\]