mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-16 01:06:56 +08:00
Add "mse" metric option to ALSTM.metric_fn (#1810)
This commit is contained in:
@@ -160,6 +160,10 @@ class ALSTM(Model):
|
|||||||
|
|
||||||
if self.metric in ("", "loss"):
|
if self.metric in ("", "loss"):
|
||||||
return -self.loss_fn(pred[mask], label[mask])
|
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)
|
raise ValueError("unknown metric `%s`" % self.metric)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user