1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-14 00:06:58 +08:00

Update training setting.

This commit is contained in:
lwwang1995
2020-11-27 10:09:17 +08:00
parent 13c2c41d23
commit 6fb19eb58d
11 changed files with 91 additions and 50 deletions

View File

@@ -46,7 +46,7 @@ class LSTM(Model):
dropout=0.0,
n_epochs=200,
lr=0.001,
metric="loss",
metric="",
batch_size=2000,
early_stop=20,
loss="mse",
@@ -140,16 +140,12 @@ class LSTM(Model):
def metric_fn(self, pred, label):
mask = torch.isfinite(label)
if self.metric == "IC":
return self.cal_ic(pred[mask], label[mask])
if self.metric == "" or self.metric == "loss": # use loss
return -self.loss_fn(pred[mask], label[mask])
raise ValueError("unknown metric `%s`" % self.metric)
def cal_ic(self, pred, label):
return torch.mean(pred * label)
def train_epoch(self, x_train, y_train):
@@ -193,7 +189,6 @@ class LSTM(Model):
losses = []
indices = np.arange(len(x_values))
np.random.shuffle(indices)
for i in range(len(indices))[:: self.batch_size]: