-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcustom_types.py
More file actions
59 lines (49 loc) · 1.47 KB
/
Copy pathcustom_types.py
File metadata and controls
59 lines (49 loc) · 1.47 KB
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
import collections
import typing
import json
import numpy as np
import torch
class TrainConfig(typing.NamedTuple):
past_T: int
forecast_T: int
train_size: int
batch_size: int
hidden_size: int
feature_size: int
out_feats: int
lr: float
logname: str
subName: str
epochs: int
l1: float
l2: float
patience: int
data: str
numFeature: int
@classmethod
def from_dict(cls,dikt):
past_T = dikt['past_T']
forecast_T = dikt['forecast_T']
train_size = dikt['train_size']
batch_size = dikt['batch_size']
hidden_size = dikt['hidden_size']
feature_size = dikt['feature_size']
out_feats = dikt['out_feats']
lr = dikt['lr']
logname = dikt["logname"]
subName = dikt["subName"]
epochs = dikt["epochs"]
l1 = dikt["l1"]
l2 = dikt["l2"]
patience = dikt["patience"]
data = dikt["data"]
numFeature = dikt["numFeature"]
return cls(past_T, forecast_T, train_size,batch_size,hidden_size,feature_size,out_feats,lr,logname,subName,epochs,l1,l2,patience,data,numFeature)
class TrainData(typing.NamedTuple):
feats: np.ndarray
targs: np.ndarray
class TestData(typing.NamedTuple):
feats: np.ndarray
targs: np.ndarray
# ANLF = collections.namedtuple("ANLF", ["encoder", "decoder", "feature", "enc_opt", "dec_opt", "fea_opt"])
ANLF = collections.namedtuple("ANLF", ["encoder", "decoder", "feature", "opt"])