compress_ridge_matrices#

torchdyno.optim.ridge_regression.compress_ridge_matrices(A, B, perc_rec, alpha)[source]#

Masks the matrices A and B according to the percentage of recurrent neurons to be used. The perc_rec percentage of the most important recurrent neurons are used, where the importance is measured by the sum of the squares of the columns of B.

Parameters:
  • A (Tensor) – YS^T

  • B (Tensor) – SS^T

  • perc_rec (Optional[float], optional) – percentage of the recurrent neurons to be used. If None, all the recurrent neurons are used. Defaults to None.

  • alpha (Optional[float], 1.0) – use alpha recurrent neurons based on importance and (1-alpha) random neurons over the fraction of all recurrent neurons given by perc_rec. Defaults to 1.0.

Returns:

the masked matrices A and B.

Return type:

Tuple[Tensor, Tensor]

Raises:

ValueError – if perc_rec or alpha are not in [0, 1]