Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the HIST and IGMTF model on Alpha360 #1040

Merged
merged 12 commits into from
Apr 13, 2022
Prev Previous commit
Next Next commit
fix the bugs of pylint
  • Loading branch information
Wentao-Xu committed Apr 13, 2022
commit 8827e11d4b6250af650aced2e34a9eea90c86529
7 changes: 1 addition & 6 deletions qlib/contrib/model/pytorch_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def __init__(
"\nd_feat : {}"
"\nhidden_size : {}"
"\nnum_layers : {}"
"\ndropout : {}"
"\nn_epochs : {}"
"\nlr : {}"
"\nmetric : {}"
Expand All @@ -97,13 +96,11 @@ def __init__(
"\nloss_type : {}"
"\nbase_model : {}"
"\nstock2concept : {}"
"\nstock_index : {}"
"\nuse_GPU : {}"
"\nseed : {}".format(
d_feat,
hidden_size,
num_layers,
dropout,
n_epochs,
lr,
metric,
Expand All @@ -113,7 +110,6 @@ def __init__(
base_model,
model_path,
stock2concept,
stock_index,
GPU,
seed,
)
Expand Down Expand Up @@ -425,8 +421,7 @@ def cal_cos_similarity(self, x, y): # the 2nd dimension of x and y are the same
xy = x.mm(torch.t(y))
x_norm = torch.sqrt(torch.sum(x * x, dim=1)).reshape(-1, 1)
y_norm = torch.sqrt(torch.sum(y * y, dim=1)).reshape(-1, 1)
cos_similarity = xy / x_norm.mm(torch.t(y_norm))
cos_similarity[cos_similarity != cos_similarity] = 0
cos_similarity = xy / (x_norm.mm(torch.t(y_norm)) + 1e-6)
return cos_similarity

def forward(self, x, concept_matrix):
Expand Down
3 changes: 1 addition & 2 deletions qlib/contrib/model/pytorch_igmtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ def cal_cos_similarity(self, x, y): # the 2nd dimension of x and y are the same
xy = x.mm(torch.t(y))
x_norm = torch.sqrt(torch.sum(x * x, dim=1)).reshape(-1, 1)
y_norm = torch.sqrt(torch.sum(y * y, dim=1)).reshape(-1, 1)
cos_similarity = xy / x_norm.mm(torch.t(y_norm))
cos_similarity[cos_similarity != cos_similarity] = 0
cos_similarity = xy / (x_norm.mm(torch.t(y_norm)) + 1e-6)
return cos_similarity

def sparse_dense_mul(self, s, d):
Expand Down