symforce.opt.residual_block module

class ResidualBlock(residual, extra_values=None)[source]

Bases: object

A single residual vector, with associated extra values. The extra values are not used in the optimization, but are intended to be additional outputs used for debugging or other purposes.

Parameters:
residual: Matrix
extra_values: Optional[Dataclass] = None
compute_jacobians(inputs, residual_name=None, key_names=None)[source]

Compute the jacobians of this residual block with respect to a sequence of inputs

Parameters:
  • inputs (Sequence[Any]) – Sequence of inputs to differentiate with respect to

  • residual_name (Optional[str]) – Optional human-readable name of the residual to be used for debug messages

  • key_names (Optional[Sequence[str]]) – Optional sequence of human-readable names for the inputs to be used for debug messages

Return type:

Sequence[Matrix]

Returns:

Sequence of jacobians of the residual with respect to each entry in inputs

__init__(residual, extra_values=None)
Parameters:
class ResidualBlockWithCustomJacobian(residual, extra_values=None, custom_jacobians=<factory>)[source]

Bases: ResidualBlock

A residual block, with a custom jacobian for the residual

This should generally only be used if you want to override the jacobian computed by SymForce, e.g. to stop derivatives with respect to certain variables or directions, or because the jacobian can be analytically simplified in a way that SymForce won’t do automatically. The custom_jacobians field should then be filled out with a mapping from all inputs to the residual which may be differentiated with respect to, to the desired jacobian of the residual with respect to each of those inputs.

Parameters:
custom_jacobians: Dict[Any, Matrix]
compute_jacobians(inputs, residual_name=None, key_names=None)[source]

Compute the jacobians of this residual block with respect to a sequence of inputs

Parameters:
  • inputs (Sequence[Any]) – Sequence of inputs to differentiate with respect to

  • residual_name (Optional[str]) – Optional human-readable name of the residual to be used for debug messages

  • key_names (Optional[Sequence[str]]) – Optional sequence of human-readable names for the inputs to be used for debug messages

Return type:

Sequence[Matrix]

Returns:

Sequence of jacobians of the residual with respect to each entry in inputs

__init__(residual, extra_values=None, custom_jacobians=<factory>)
Parameters: