From 09d66a37a7674a6bdd47ebc23af7458d04692e28 Mon Sep 17 00:00:00 2001 From: QIN DING Date: Wed, 4 Jan 2023 11:44:22 -0800 Subject: [PATCH] Fix matrix inverse for joint LinUCB Summary: This is a copy of D42322767 to fix the inverse of ill-conditioned matrix for joint LinUCB Reviewed By: alexnikulkov Differential Revision: D42334903 fbshipit-source-id: d49805d9260da56c3a411ad0eb6dbdd9010f5184 --- reagent/models/linear_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reagent/models/linear_regression.py b/reagent/models/linear_regression.py index e672028f..b326654d 100644 --- a/reagent/models/linear_regression.py +++ b/reagent/models/linear_regression.py @@ -104,7 +104,7 @@ def _calculate_coefs(self) -> None: self.cur_sum_weight, reduce_op=ReduceOp.SUM ) - self.inv_A = torch.inverse( + self.inv_A = torch.linalg.pinv( self.A + self.l2_reg_lambda * torch.eye(