-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
67 lines (46 loc) · 1.87 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
import warnings
import torch as t
class DefaultConfig(object):
model = 'LSTM'
data = 'NINO3'
load_model_path = None
input_size, output_size = None, None
needLog = None
tr_va_te = None
encoder_hidden_size = 64 # 64,128,256
decoder_hidden_size = 64 # 64,128,256
batch_size = 16 # 7, 3
T, future = 64, 4
use_gpu = True
print_freq = 20
model_list_path = [None, None, None, None] # 0:aucoencoder 1:seq2seq 2:recurrent 3:fusion
train_test_pre = 2
data_list_index = 0
recurrent_n = 1
max_epoch = 2500
lr = 0.01 # initial learning rate
lr_decay = .95 # when val_loss incress, lr = lr * lr_dacay
weight_decay = 1e-5
num = 15 # for test & val
device = t.device('cuda') if use_gpu else t.device('cpu')
_input_kv = {'ExchangeRate':8, 'NINO':1, 'Yahoo':1, 'Wecar':5, 'Aircraft':2, 'BJpm':4,'GEFCom2014_Task1_P':1}
_output_kv = {'ExchangeRate':8, 'NINO':1, 'Yahoo':1, 'Wecar':5, 'Aircraft':2, 'BJpm':4,'GEFCom2014_Task1_P':1}
_needLog_kv = {'ExchangeRate':False, 'NINO':True, 'Yahoo':True, 'Wecar':False, 'Aircraft':True, 'BJpm':False,'GEFCom2014_Task1_P':True}
def _parse(self, kwargs = {}, printconfig = False):
'''
更新参数
'''
for k, v in kwargs.items():
if not hasattr(self, k):
warnings.warn('Warning: opt has not attribute %s' % k)
setattr(self, k, v)
if printconfig:
print('\nuser config:')
for k, v in self.__class__.__dict__.items():
if not k.startswith('_'):
print(k, getattr(self, k))
opt = DefaultConfig()
if __name__ == '__main__':
opt._parse(printconfig = True)
print(opt.lr)