Skip to content

Commit

Permalink
Add "mse" metric option to ALSTM.metric_fn (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
raikiriww authored Jun 19, 2024
1 parent 155c17f commit 73ec0f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qlib/contrib/model/pytorch_alstm_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def metric_fn(self, pred, label):

if self.metric in ("", "loss"):
return -self.loss_fn(pred[mask], label[mask])
elif self.metric == "mse":
mask = ~torch.isnan(label)
weight = torch.ones_like(label)
return -self.mse(pred[mask], label[mask], weight[mask])

raise ValueError("unknown metric `%s`" % self.metric)

Expand Down

0 comments on commit 73ec0f4

Please sign in to comment.