DualProj

class torchjd.aggregation.DualProj(pref_vector=None, projector=None)[source]

GramianWeightedAggregator that averages the rows of the input matrix, and projects the result onto the dual cone of the rows of the matrix. This corresponds to the solution to Equation 11 of Gradient Episodic Memory for Continual Learning.

Parameters:
  • pref_vector (Tensor | None) – The preference vector used to combine the rows. If not provided, defaults to \(\begin{bmatrix} \frac{1}{m} & \dots & \frac{1}{m} \end{bmatrix}^T \in \mathbb{R}^m\).

  • projector (DualConeProjector | None) – The DualConeProjector used to compute the projection.

__call__(*args, **kwargs)[source]

Computes the aggregation from the input matrix and applies all registered hooks.

Parameters:

matrix – The Jacobian to aggregate.

Return type:

Any

class torchjd.aggregation.DualProjWeighting(pref_vector=None, projector=None)[source]

Weighting [PSDMatrix] giving the weights of DualProj.

Parameters:
  • pref_vector (Tensor | None) – The preference vector to use. If not provided, defaults to \(\begin{bmatrix} \frac{1}{m} & \dots & \frac{1}{m} \end{bmatrix}^T \in \mathbb{R}^m\).

  • projector (DualConeProjector | None) – The DualConeProjector used to compute the projection.

__call__(*args, **kwargs)[source]

Computes the vector of weights from the input Gramian and applies all registered hooks.

Parameters:

gramian – The Gramian from which the weights must be extracted.

Return type:

Any