Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing issue 1780 #1790

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion qlib/contrib/model/pytorch_alstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def loss_fn(self, pred, label):
def metric_fn(self, pred, label):
mask = torch.isfinite(label)

if self.metric in ("", "loss"):
if self.metric in ("", "loss","mse"):
return -self.loss_fn(pred[mask], label[mask])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use mse instead of loss_fn to support extending more losses in the future.


raise ValueError("unknown metric `%s`" % self.metric)
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/model/pytorch_alstm_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def loss_fn(self, pred, label, weight=None):
def metric_fn(self, pred, label):
mask = torch.isfinite(label)

if self.metric in ("", "loss"):
if self.metric in ("", "loss","mse"):
return -self.loss_fn(pred[mask], label[mask])

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