1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-14 00:06:58 +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

@@ -150,7 +150,7 @@ class DNNModelPytorch(Model):
eps=1e-08,
)
self._fitted = False
self.fitted = False
self.dnn_model.to(self.device)
def fit(
@@ -180,7 +180,7 @@ class DNNModelPytorch(Model):
evals_result["valid"] = []
# train
self.logger.info("training...")
self._fitted = True
self.fitted = True
# return
# prepare training data
x_train_values = torch.from_numpy(x_train.values).float()
@@ -265,7 +265,7 @@ class DNNModelPytorch(Model):
raise NotImplementedError("loss {} is not supported!".format(loss_type))
def predict(self, dataset):
if not self._fitted:
if not self.fitted:
raise ValueError("model is not fitted yet!")
x_test_pd = dataset.prepare("test", col_set="feature")
x_test = torch.from_numpy(x_test_pd.values).float().to(self.device)