1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-15 08:46:56 +08:00

Update models to enable save/load

This commit is contained in:
Jactus
2021-02-04 17:23:10 +08:00
committed by you-n-g
parent 6a670828a5
commit b84686b215
12 changed files with 35 additions and 34 deletions

View File

@@ -130,7 +130,7 @@ class LSTM(Model):
else:
raise NotImplementedError("optimizer {} is not supported!".format(optimizer))
self._fitted = False
self.fitted = False
self.lstm_model.to(self.device)
def mse(self, pred, label):
@@ -238,7 +238,7 @@ class LSTM(Model):
# train
self.logger.info("training...")
self._fitted = True
self.fitted = True
for step in range(self.n_epochs):
self.logger.info("Epoch%d:", step)
@@ -270,7 +270,7 @@ class LSTM(Model):
torch.cuda.empty_cache()
def predict(self, dataset):
if not self._fitted:
if not self.fitted:
raise ValueError("model is not fitted yet!")
x_test = dataset.prepare("test", col_set="feature")