You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running the train.py, error "Unable to solve the normal equations in LinearFeatureBaseline. The matrix X^T*X (with X the design matrix) is not full-rank, regardless of the regularization (maximum regularization: 1.0)." occurs.
#72
Open
bianca-li-bupt opened this issue
Mar 1, 2023
· 0 comments
Replace the 'torch.lstsq' with 'torch.linalg.lstsq'. Because the former function was removed.
Output coeffs is an instance now, not a tensor. So use coeffs.solution referring to the value.
for _ in range(5):
try:
coeffs= torch.linalg.lstsq(XT_y, XT_X + reg_coeff * self._eye, driver='gelsy')
# coeffs,_ = torch.lstsq(XT_y, XT_X + reg_coeff * self._eye)
# An extra round of increasing regularization eliminated
# inf or nan in the least-squares solution most of the time
if torch.isnan(coeffs.solution).any() or torch.isinf(coeffs.solution).any():
raise RuntimeError
break
except RuntimeError:
reg_coeff *= 10
else:
raise RuntimeError('Unable to solve the normal equations in '
'`LinearFeatureBaseline`. The matrix X^T*X (with X the design '
'matrix) is not full-rank, regardless of the regularization '
'(maximum regularization: {0}).'.format(reg_coeff))
self.weight.copy_(coeffs.solution.flatten())
The text was updated successfully, but these errors were encountered:
The solution is as below.
In baseline.py line 60:
The text was updated successfully, but these errors were encountered: