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

Fix code with block.

This commit is contained in:
lwwang1995
2020-11-27 22:44:28 +08:00
parent c5a3b74a96
commit 1353e81b5b
7 changed files with 42 additions and 136 deletions

View File

@@ -124,9 +124,7 @@ class GRU(Model):
elif optimizer.lower() == "gd":
self.train_optimizer = optim.SGD(self.gru_model.parameters(), lr=self.lr)
else:
raise NotImplementedError(
"optimizer {} is not supported!".format(optimizer)
)
raise NotImplementedError("optimizer {} is not supported!".format(optimizer))
self._fitted = False
if self.use_gpu:
@@ -171,12 +169,8 @@ class GRU(Model):
if len(indices) - i < self.batch_size:
break
feature = torch.from_numpy(
x_train_values[indices[i : i + self.batch_size]]
).float()
label = torch.from_numpy(
y_train_values[indices[i : i + self.batch_size]]
).float()
feature = torch.from_numpy(x_train_values[indices[i : i + self.batch_size]]).float()
label = torch.from_numpy(y_train_values[indices[i : i + self.batch_size]]).float()
if self.use_gpu:
feature = feature.cuda()
@@ -208,9 +202,7 @@ class GRU(Model):
if len(indices) - i < self.batch_size:
break
feature = torch.from_numpy(
x_values[indices[i : i + self.batch_size]]
).float()
feature = torch.from_numpy(x_values[indices[i : i + self.batch_size]]).float()
label = torch.from_numpy(y_values[indices[i : i + self.batch_size]]).float()
if self.use_gpu: