1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 22:36:55 +08:00

[807] Move the REG_CONSTANT/EPS to constant.py. (#811)

* [807] Move the REG_CONSTANT to constant.py.

* import REG_US.

* Move EPS to constant.py.
This commit is contained in:
Chia-hung Tai
2022-01-09 21:39:46 +08:00
committed by GitHub
parent 382ababc01
commit 184ce34a34
26 changed files with 42 additions and 35 deletions

View File

@@ -25,6 +25,7 @@ except:
from tqdm import tqdm
from qlib.utils import get_or_create_path
from qlib.constant import EPS
from qlib.log import get_module_logger
from qlib.model.base import Model
from qlib.contrib.data.dataset import MTSDatasetH
@@ -791,7 +792,7 @@ def minmax_norm(x):
xmin = x.min(dim=-1, keepdim=True).values
xmax = x.max(dim=-1, keepdim=True).values
mask = (xmin == xmax).squeeze()
x = (x - xmin) / (xmax - xmin + 1e-12)
x = (x - xmin) / (xmax - xmin + EPS)
x[mask] = 1
return x