Skip to content

Commit

Permalink
rcond parameter in np.linalg.lstsq
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusMNoack committed Sep 14, 2022
1 parent 8b98c33 commit d9198ff
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fvgp/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,11 @@ def solve(self, A, b):
try:
logger.error("torch.solve() on cpu did not work")
logger.error("reason: ", str(e))
#x, qr = torch.lstsq(b,A)
x, res, rank, s = torch.linalg.lstsq(A,b)
except Exception as e:
logger.error("torch.solve() and torch.lstsq() on cpu did not work; falling back to numpy.linalg.lstsq()")
logger.error("reason: {}", str(e))
x,res,rank,s = np.linalg.lstsq(A.numpy(),b.numpy())
x,res,rank,s = np.linalg.lstsq(A.numpy(),b.numpy(),rcond=None)
return x
return x.numpy()
elif self.compute_device == "gpu" or A.ndim < 3:
Expand All @@ -747,12 +746,11 @@ def solve(self, A, b):
logger.error("torch.solve() on gpu did not work")
logger.error("reason: ", str(e))
try:
#x, qr = torch.lstsq(b,A)
x = torch.linalg.lstsq(A,b)
except Exception as e:
logger.error("torch.solve() and torch.lstsq() on gpu did not work; falling back to numpy.linalg.lstsq()")
logger.error("reason: ", str(e))
x,res,rank,s = np.linalg.lstsq(A.numpy(),b.numpy())
x,res,rank,s = np.linalg.lstsq(A.numpy(),b.numpy(),rcond=None)
return x
return x.cpu().numpy()
elif self.compute_device == "multi-gpu":
Expand Down

0 comments on commit d9198ff

Please sign in to comment.