MCPcopy Create free account
hub / github.com/Anoise/WTFlib / __init__

Method __init__

LDPS_Graph/models/PatchTST.py:16–78  ·  view source on GitHub ↗
(self, configs, max_seq_len:Optional[int]=1024, d_k:Optional[int]=None, d_v:Optional[int]=None, norm:str='BatchNorm', attn_dropout:float=0., 
                 act:str="gelu", key_padding_mask:bool='auto',padding_var:Optional[int]=None, attn_mask:Optional[Tensor]=None, res_attention:bool=True, 
                 pre_norm:bool=False, store_attn:bool=False, pe:str='zeros', learn_pe:bool=True, pretrain_head:bool=False, head_type = 'flatten', verbose:bool=False, **kwargs)

Source from the content-addressed store, hash-verified

14
15class Model(nn.Module):
16 def __init__(self, configs, max_seq_len:Optional[int]=1024, d_k:Optional[int]=None, d_v:Optional[int]=None, norm:str='BatchNorm', attn_dropout:float=0.,
17 act:str="gelu", key_padding_mask:bool='auto',padding_var:Optional[int]=None, attn_mask:Optional[Tensor]=None, res_attention:bool=True,
18 pre_norm:bool=False, store_attn:bool=False, pe:str='zeros', learn_pe:bool=True, pretrain_head:bool=False, head_type = 'flatten', verbose:bool=False, **kwargs):
19
20 super().__init__()
21
22 # load parameters
23 c_in = configs.enc_in
24 context_window = configs.seq_len
25 target_window = configs.pred_len
26
27 n_layers = configs.e_layers
28 n_heads = configs.n_heads
29 d_model = configs.d_model
30 d_ff = configs.d_ff
31 dropout = configs.dropout
32 fc_dropout = configs.fc_dropout
33 head_dropout = configs.head_dropout
34
35 individual = configs.individual
36
37 patch_len = configs.patch_len
38 stride = configs.stride
39 padding_patch = configs.padding_patch
40
41 revin = configs.revin
42 affine = configs.affine
43 subtract_last = configs.subtract_last
44
45 decomposition = configs.decomposition
46 kernel_size = configs.kernel_size
47
48
49 # model
50 self.decomposition = decomposition
51 print(self.decomposition,'---->>>>')
52 if self.decomposition:
53 self.decomp_module = series_decomp(kernel_size)
54 self.model_trend = PatchTST_backbone(c_in=c_in, context_window = context_window, target_window=target_window, patch_len=patch_len, stride=stride,
55 max_seq_len=max_seq_len, n_layers=n_layers, d_model=d_model,
56 n_heads=n_heads, d_k=d_k, d_v=d_v, d_ff=d_ff, norm=norm, attn_dropout=attn_dropout,
57 dropout=dropout, act=act, key_padding_mask=key_padding_mask, padding_var=padding_var,
58 attn_mask=attn_mask, res_attention=res_attention, pre_norm=pre_norm, store_attn=store_attn,
59 pe=pe, learn_pe=learn_pe, fc_dropout=fc_dropout, head_dropout=head_dropout, padding_patch = padding_patch,
60 pretrain_head=pretrain_head, head_type=head_type, individual=individual, revin=revin, affine=affine,
61 subtract_last=subtract_last, verbose=verbose, **kwargs)
62 self.model_res = PatchTST_backbone(c_in=c_in, context_window = context_window, target_window=target_window, patch_len=patch_len, stride=stride,
63 max_seq_len=max_seq_len, n_layers=n_layers, d_model=d_model,
64 n_heads=n_heads, d_k=d_k, d_v=d_v, d_ff=d_ff, norm=norm, attn_dropout=attn_dropout,
65 dropout=dropout, act=act, key_padding_mask=key_padding_mask, padding_var=padding_var,
66 attn_mask=attn_mask, res_attention=res_attention, pre_norm=pre_norm, store_attn=store_attn,
67 pe=pe, learn_pe=learn_pe, fc_dropout=fc_dropout, head_dropout=head_dropout, padding_patch = padding_patch,
68 pretrain_head=pretrain_head, head_type=head_type, individual=individual, revin=revin, affine=affine,
69 subtract_last=subtract_last, verbose=verbose, **kwargs)
70 else:
71 self.model = PatchTST_backbone(c_in=c_in, context_window = context_window, target_window=target_window, patch_len=patch_len, stride=stride,
72 max_seq_len=max_seq_len, n_layers=n_layers, d_model=d_model,
73 n_heads=n_heads, d_k=d_k, d_v=d_v, d_ff=d_ff, norm=norm, attn_dropout=attn_dropout,

Callers

nothing calls this directly

Calls 2

series_decompClass · 0.90
PatchTST_backboneClass · 0.90

Tested by

no test coverage detected