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

Fix bugs in use_gpu

This commit is contained in:
D-X-Y
2021-03-11 19:10:32 -08:00
parent db59713d36
commit d38b8d6001
9 changed files with 10 additions and 13 deletions

View File

@@ -134,7 +134,7 @@ class LSTM(Model):
@property
def use_gpu(self):
self.device == torch.device("cpu")
self.device != torch.device("cpu")
def mse(self, pred, label):
loss = (pred - label) ** 2
@@ -291,10 +291,7 @@ class LSTM(Model):
x_batch = torch.from_numpy(x_values[begin:end]).float().to(self.device)
with torch.no_grad():
if self.use_gpu:
pred = self.lstm_model(x_batch).detach().cpu().numpy()
else:
pred = self.lstm_model(x_batch).detach().numpy()
pred = self.lstm_model(x_batch).detach().cpu().numpy()
preds.append(pred)