mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 00:06:58 +08:00
update model
This commit is contained in:
@@ -51,4 +51,3 @@ qlib_data:
|
|||||||
# when testing, please modify the following parameters according to the specific environment
|
# when testing, please modify the following parameters according to the specific environment
|
||||||
provider_uri: "~/.qlib/qlib_data/cn_data"
|
provider_uri: "~/.qlib/qlib_data/cn_data"
|
||||||
region: "cn"
|
region: "cn"
|
||||||
redis_port: 1222
|
|
||||||
|
|||||||
@@ -48,11 +48,8 @@ backtest:
|
|||||||
open_cost: 0.0005
|
open_cost: 0.0005
|
||||||
close_cost: 0.0015
|
close_cost: 0.0015
|
||||||
min_cost: 5
|
min_cost: 5
|
||||||
long_short_backtest_args:
|
|
||||||
topk: 50
|
|
||||||
|
|
||||||
qlib_data:
|
qlib_data:
|
||||||
# when testing, please modify the following parameters according to the specific environment
|
# when testing, please modify the following parameters according to the specific environment
|
||||||
provider_uri: "~/.qlib/qlib_data/cn_data"
|
provider_uri: "~/.qlib/qlib_data/cn_data"
|
||||||
region: "cn"
|
region: "cn"
|
||||||
redis_port: 1222
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class DNNModelPytorch(Model):
|
|||||||
self,
|
self,
|
||||||
input_dim,
|
input_dim,
|
||||||
output_dim,
|
output_dim,
|
||||||
layers=(256, 256, 128),
|
layers=(256, 512, 768, 1024, 768, 512, 256, 128, 64),
|
||||||
lr=0.001,
|
lr=0.001,
|
||||||
max_steps=300,
|
max_steps=300,
|
||||||
batch_size=2000,
|
batch_size=2000,
|
||||||
@@ -76,6 +76,7 @@ class DNNModelPytorch(Model):
|
|||||||
self.optimizer = optimizer.lower()
|
self.optimizer = optimizer.lower()
|
||||||
self.loss_type = loss
|
self.loss_type = loss
|
||||||
self.visible_GPU = GPU
|
self.visible_GPU = GPU
|
||||||
|
self.use_gpu = torch.cuda.is_available()
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"DNN parameters setting:"
|
"DNN parameters setting:"
|
||||||
@@ -90,7 +91,8 @@ class DNNModelPytorch(Model):
|
|||||||
"\noptimizer : {}"
|
"\noptimizer : {}"
|
||||||
"\nloss_type : {}"
|
"\nloss_type : {}"
|
||||||
"\neval_steps : {}"
|
"\neval_steps : {}"
|
||||||
"\nvisible_GPU : {}".format(
|
"\nvisible_GPU : {}"
|
||||||
|
"\nuse_GPU : {}".format(
|
||||||
layers,
|
layers,
|
||||||
lr,
|
lr,
|
||||||
max_steps,
|
max_steps,
|
||||||
@@ -103,6 +105,7 @@ class DNNModelPytorch(Model):
|
|||||||
loss,
|
loss,
|
||||||
eval_steps,
|
eval_steps,
|
||||||
GPU,
|
GPU,
|
||||||
|
self.use_gpu,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -133,7 +136,7 @@ class DNNModelPytorch(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._fitted = False
|
self._fitted = False
|
||||||
self.use_gpu = torch.cuda.is_available()
|
|
||||||
|
|
||||||
if self.use_gpu:
|
if self.use_gpu:
|
||||||
self.dnn_model.cuda()
|
self.dnn_model.cuda()
|
||||||
@@ -327,20 +330,20 @@ class AverageMeter(object):
|
|||||||
|
|
||||||
|
|
||||||
class Net(nn.Module):
|
class Net(nn.Module):
|
||||||
def __init__(self, input_dim, output_dim, layers=(256, 256, 256), loss="mse"):
|
def __init__(self, input_dim, output_dim, layers=(256, 512, 768, 512, 256, 128, 64), loss="mse"):
|
||||||
super(Net, self).__init__()
|
super(Net, self).__init__()
|
||||||
layers = [input_dim] + list(layers)
|
layers = [input_dim] + list(layers)
|
||||||
dnn_layers = []
|
dnn_layers = []
|
||||||
drop_input = nn.Dropout(0.1)
|
drop_input = nn.Dropout(0.05)
|
||||||
dnn_layers.append(drop_input)
|
dnn_layers.append(drop_input)
|
||||||
for i, (input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):
|
for i, (input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):
|
||||||
fc = nn.Linear(input_dim, hidden_units)
|
fc = nn.Linear(input_dim, hidden_units)
|
||||||
activation = nn.ReLU()
|
activation = nn.ReLU()
|
||||||
bn = nn.BatchNorm1d(hidden_units)
|
bn = nn.BatchNorm1d(hidden_units)
|
||||||
drop = nn.Dropout(0.1)
|
seq = nn.Sequential(fc, bn, activation)
|
||||||
seq = nn.Sequential(fc, bn, activation, drop)
|
|
||||||
dnn_layers.append(seq)
|
dnn_layers.append(seq)
|
||||||
|
drop_input = nn.Dropout(0.05)
|
||||||
|
dnn_layers.append(drop_input)
|
||||||
if loss == "mse":
|
if loss == "mse":
|
||||||
fc = nn.Linear(hidden_units, output_dim)
|
fc = nn.Linear(hidden_units, output_dim)
|
||||||
dnn_layers.append(fc)
|
dnn_layers.append(fc)
|
||||||
|
|||||||
Reference in New Issue
Block a user