Skip to content

Commit

Permalink
Added total ridge regression even with simple inverse
Browse files Browse the repository at this point in the history
  • Loading branch information
nschaetti committed Jan 17, 2019
1 parent 744828c commit 9bebeb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion echotorch/nn/RRCell.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def finalize(self):
Finalize training with LU factorization or Pseudo-inverse
"""
if self.learning_algo == 'inv':
inv_xTx = self.xTx.inverse()
# inv_xTx = self.xTx.inverse()
# inv_xTx = torch.inverse(self.xTx + self.ridge_param * torch.eye(self._input_dim + self.with_bias))
ridge_xTx = self.xTx + self.ridge_param * torch.eye(self._input_dim + self.with_bias)
inv_xTx = ridge_xTx.inverse()
self.w_out.data = torch.mm(inv_xTx, self.xTy).data
else:
self.w_out.data = torch.gesv(self.xTy, self.xTx + torch.eye(self.esn_cell.output_dim).mul(self.ridge_param)).data
Expand Down

0 comments on commit 9bebeb0

Please sign in to comment.