spyrit.core.torch.regularized_lstsq

spyrit.core.torch.regularized_lstsq(A: tensor, y: tensor, regularization: str, **kwargs)[source]

Batched regularized least squares solution of a system of equations.

It solves the linear system of equations \(Ax = y\) using a regularized least squares method. The regularizations supported are:

  • “rcond”: Uses the function torch.linalg.lstsq(). Additional

    arguments can be passed to this function through the kwargs parameters, such as rcond or driver. They are given to the function torch.linalg.lstsq().

  • “L2”: Uses the L2 regularization method. The regularization parameter

    eta must be passed as a keyword argument. It controls the amount of regularization applied to the least squares solution.

  • “H1”: Uses the H1 regularization method. The regularization parameter

    eta must be passed as a keyword argument. It controls the amount of regularization applied to the least squares solution. This method is only implemented for 2D images.

Args:

A (torch.tensor): Left-hand side tensor of shape \((m, n)\), where * is any number of batch dimensions.

y (torch.tensor): Right-hand side tensor of shape \((*, m)\), where * is any number of batch dimensions.

regularization (str): Regularization method to use. Supported methods are “rcond”, “L2”, and “H1”.

**kwargs: Additional keyword arguments to pass to the regularization method. Must include the regularization parameter eta when using the “L2” and “H1” regularization methods. Other keyword arguments include rcond and driver for the “rcond” method, as well as ‘D2’ (the finite difference matrices) for the “H1” and “L2” methods.

Returns:

torch.tensor: The regularized least squares solution of shape \((*, n)\).