(self, c_in, patch_num, patch_len, max_seq_len=1024,
n_layers=3, d_model=128, n_heads=16, d_k=None, d_v=None,
d_ff=256, norm='BatchNorm', attn_dropout=0., dropout=0., act="gelu", store_attn=False,
key_padding_mask='auto', padding_var=None, attn_mask=None, res_attention=True, pre_norm=False,
pe='zeros', learn_pe=True, verbose=False, **kwargs)
| 129 | |
| 130 | class TSTiEncoder(nn.Module): #i means channel-independent |
| 131 | def __init__(self, c_in, patch_num, patch_len, max_seq_len=1024, |
| 132 | n_layers=3, d_model=128, n_heads=16, d_k=None, d_v=None, |
| 133 | d_ff=256, norm='BatchNorm', attn_dropout=0., dropout=0., act="gelu", store_attn=False, |
| 134 | key_padding_mask='auto', padding_var=None, attn_mask=None, res_attention=True, pre_norm=False, |
| 135 | pe='zeros', learn_pe=True, verbose=False, **kwargs): |
| 136 | |
| 137 | |
| 138 | super().__init__() |
| 139 | |
| 140 | self.patch_num = patch_num |
| 141 | self.patch_len = patch_len |
| 142 | |
| 143 | # Input encoding |
| 144 | q_len = patch_num |
| 145 | self.W_P = nn.Linear(patch_len, d_model) # Eq 1: projection of feature vectors onto a d-dim vector space |
| 146 | self.seq_len = q_len |
| 147 | |
| 148 | # Positional encoding |
| 149 | self.W_pos = positional_encoding(pe, learn_pe, q_len, d_model) |
| 150 | |
| 151 | # Residual dropout |
| 152 | self.dropout = nn.Dropout(dropout) |
| 153 | |
| 154 | # Encoder |
| 155 | self.encoder = TSTEncoder(q_len, d_model, n_heads, d_k=d_k, d_v=d_v, d_ff=d_ff, norm=norm, attn_dropout=attn_dropout, dropout=dropout, |
| 156 | pre_norm=pre_norm, activation=act, res_attention=res_attention, n_layers=n_layers, store_attn=store_attn) |
| 157 | |
| 158 | |
| 159 | def forward(self, x, |
nothing calls this directly
no test coverage detected