1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-14 08:16:54 +08:00

pylint code refine & Fix nested example (#848)

* refine code by CI

* fix argument error

* fix nested eample
This commit is contained in:
you-n-g
2022-01-14 09:09:21 +08:00
committed by GitHub
parent c3996955ef
commit d0113ea7df
26 changed files with 65 additions and 68 deletions

View File

@@ -554,7 +554,7 @@ class AdaRNN(nn.Module):
return fc_out
class TransferLoss(object):
class TransferLoss:
def __init__(self, loss_type="cosine", input_dim=512):
"""
Supported loss_type: mmd(mmd_lin), mmd_rbf, coral, cosine, kl, js, mine, adv

View File

@@ -98,7 +98,6 @@ class DNNModelPytorch(Model):
"\nlr_decay_steps : {}"
"\noptimizer : {}"
"\nloss_type : {}"
"\neval_steps : {}"
"\nseed : {}"
"\ndevice : {}"
"\nuse_GPU : {}"
@@ -113,7 +112,6 @@ class DNNModelPytorch(Model):
lr_decay_steps,
optimizer,
loss,
eval_steps,
seed,
self.device,
self.use_gpu,
@@ -331,8 +329,8 @@ class Net(nn.Module):
dnn_layers = []
drop_input = nn.Dropout(0.05)
dnn_layers.append(drop_input)
for i, (input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):
fc = nn.Linear(input_dim, hidden_units)
for i, (_input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):
fc = nn.Linear(_input_dim, hidden_units)
activation = nn.LeakyReLU(negative_slope=0.1, inplace=False)
bn = nn.BatchNorm1d(hidden_units)
seq = nn.Sequential(fc, bn, activation)

View File

@@ -19,7 +19,7 @@ import torch.nn.functional as F
try:
from torch.utils.tensorboard import SummaryWriter
except:
except ImportError:
SummaryWriter = None
from tqdm import tqdm
@@ -257,7 +257,7 @@ class TRAModel(Model):
total_loss += loss.item()
total_count += 1
if self.use_daily_transport and len(P_all):
if self.use_daily_transport and len(P_all) > 0:
P_all = pd.concat(P_all, axis=0)
prob_all = pd.concat(prob_all, axis=0)
choice_all = pd.concat(choice_all, axis=0)