DualProj

class torchjd.aggregation.dualproj.DualProj(pref_vector=None, norm_eps=0.0001, reg_eps=0.0001, solver='quadprog')

Aggregator 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 the simple averaging.

  • norm_eps (float) – A small value to avoid division by zero when normalizing.

  • reg_eps (float) – A small value to add to the diagonal of the gramian of the matrix. Due to numerical errors when computing the gramian, it might not exactly be positive definite. This issue can make the optimization fail. Adding reg_eps to the diagonal of the gramian ensures that it is positive definite.

  • solver (Literal['quadprog']) – The solver used to optimize the underlying optimization problem.

Example

Use DualProj to aggregate a matrix.

>>> from torch import tensor
>>> from torchjd.aggregation import DualProj
>>>
>>> A = DualProj()
>>> J = tensor([[-4., 1., 1.], [6., 1., 1.]])
>>>
>>> A(J)
tensor([0.5563, 1.1109, 1.1109])