Correlation

class colibri.regularizers.Correlation(batch_size=128, param=0.001)[source]

Bases: Module

Correlation Regularization for the outputs of optical layers.

This regularizer computes

\[\begin{equation*} R(\mathbf{y}_1,\mathbf{y}_2) = \mu\left\|\mathbf{C_{yy_1}} - \mathbf{C_{yy_2}}\right\|_2 \end{equation*}\]

where \(\mathbf{C_{yy_1}}\) and \(\mathbf{C_{yy_2}}\) are the correlation matrices of the measurements tensors \(\mathbf{y}_1,\mathbf{y}_2 \in \yset\) and mu is a regularization parameter .

Parameters:
  • batch_size (int) – Batch size used for reshaping.

  • param (float) – Regularization parameter.

forward(inputs)[source]

Compute correlation regularization term.

Parameters:

inputs (tuple) – Tuple containing two input tensors (x and y).

Returns:

Correlation regularization term.

Return type:

torch.Tensor