|
1 | 1 | # Copyright (c) Microsoft Corporation. |
2 | 2 | # Licensed under the MIT License. |
3 | 3 |
|
| 4 | +from pathlib import Path |
| 5 | +from typing import Union |
4 | 6 | import numpy as np |
5 | 7 | import pandas as pd |
6 | 8 | import tensorflow.compat.v1 as tf |
@@ -243,7 +245,7 @@ def extract_numerical_data(data): |
243 | 245 | # extract_numerical_data(targets), extract_numerical_data(p90_forecast), |
244 | 246 | # 0.9) |
245 | 247 | tf.keras.backend.set_session(default_keras_session) |
246 | | - print("Training completed.".format(dte.datetime.now())) |
| 248 | + print("Training completed at {}.".format(dte.datetime.now())) |
247 | 249 | # ===========================Training Process=========================== |
248 | 250 |
|
249 | 251 | def predict(self, dataset): |
@@ -289,3 +291,24 @@ def finetune(self, dataset: DatasetH): |
289 | 291 | dataset for finetuning |
290 | 292 | """ |
291 | 293 | pass |
| 294 | + |
| 295 | + def to_pickle(self, path: Union[Path, str]): |
| 296 | + """ |
| 297 | + Tensorflow model can't be dumped directly. |
| 298 | + So the data should be save seperatedly |
| 299 | +
|
| 300 | + **TODO**: Please implement the function to load the files |
| 301 | +
|
| 302 | + Parameters |
| 303 | + ---------- |
| 304 | + path : Union[Path, str] |
| 305 | + the target path to be dumped |
| 306 | + """ |
| 307 | + # save tensorflow model |
| 308 | + # path = Path(path) |
| 309 | + # path.mkdir(parents=True) |
| 310 | + # self.model.save(path) |
| 311 | + |
| 312 | + # save qlib model wrapper |
| 313 | + self.model = None |
| 314 | + super(TFTModel, self).to_pickle(path / "qlib_model") |
0 commit comments