Open black-yt opened 2 months ago
+1
You can use torch.linalg.matrix_rank(A) to check the matrix's rank. In this case, we need a full-rank matrix. If not, use a regularization, may be:
# Tikhonov regularization
lambda_value = 1e-3
A_reg = A + lambda_value * torch.eye(A.size(-1))
solution, _ = torch.linalg.lstsq(A_reg, B)
when update grid:
torch._C._LinAlgError: torch.linalg.lstsq: (Batch element 1): The least squares solution could not be computed because the input matrix does not have full rank (error code: 4).
how to solve this problem? thanks!