peal.adaptors.clarc.calculate_pcav

peal.adaptors.clarc.calculate_pcav(activations, annotations)[source]

Pattern CAV: covariance of activations with the +-1 artifact label.

The labels are mapped to {-1, +1}, both sides are centred and the CAV is cov(activations, labels) / var(labels), normalised to unit length.

Parameters:
  • activations (torch.Tensor) – Shape (N, D).

  • annotations (torch.Tensor) – Shape (N,) with 0 / 1 labels (not modified in place).

Returns:

Shape (1, D).

Return type:

torch.Tensor