espnet2.enh.layers.beamformer.tik_reg
Less than 1 minute
espnet2.enh.layers.beamformer.tik_reg
espnet2.enh.layers.beamformer.tik_reg(mat, reg: float = 1e-08, eps: float = 1e-08)
Perform Tikhonov regularization on a complex matrix by modifying its real part.
Tikhonov regularization, also known as ridge regression, is a technique used to stabilize the solution of ill-posed problems by adding a regularization term. This function specifically targets the real part of the input complex matrix and adds a scaled identity matrix to it.
- Parameters:
- mat (torch.complex64/ComplexTensor) – Input matrix of shape (…, C, C), where C is the number of channels.
- reg (float) – Regularization factor that determines the strength of the regularization. A higher value applies more regularization.
- eps (float) – A small constant added to prevent division by zero or ensure numerical stability.
- Returns: Regularized matrix of shape (…, C, C).
- Return type: ret (torch.complex64/ComplexTensor)
NOTE
The regularization is applied only to the real part of the matrix. The imaginary part remains unchanged. This is particularly useful in scenarios involving covariance matrices in beamforming applications, where the real part may become ill-conditioned.
Examples
>>> import torch
>>> mat = torch.tensor([[1.0 + 2.0j, 0.0 + 1.0j], [0.0 + 1.0j, 1.0 + 0.0j]])
>>> regularized_mat = tik_reg(mat, reg=0.1, eps=1e-8)
>>> print(regularized_mat)