(self, configs)
| 32 | Vanilla Transformer with O(L^2) complexity |
| 33 | """ |
| 34 | def __init__(self, configs): |
| 35 | super(Model, self).__init__() |
| 36 | self.pred_len = configs.pred_len |
| 37 | self.output_attention = configs.output_attention |
| 38 | |
| 39 | # Embedding |
| 40 | self.enc_embedding = DataEmbedding(configs.enc_in, configs.d_model, configs.embed, configs.freq, |
| 41 | configs.dropout) |
| 42 | self.dec_embedding = DataEmbedding(configs.dec_in, configs.d_model, configs.embed, configs.freq, |
| 43 | configs.dropout) |
| 44 | # Encoder |
| 45 | self.encoder = Encoder( |
| 46 | [ |
| 47 | EncoderLayer( |
| 48 | AttentionLayer( |
| 49 | FullAttention(False, configs.factor, attention_dropout=configs.dropout, |
| 50 | output_attention=configs.output_attention), configs.d_model, configs.n_heads), |
| 51 | configs.d_model, |
| 52 | configs.d_ff, |
| 53 | dropout=configs.dropout, |
| 54 | activation=configs.activation |
| 55 | ) for l in range(configs.e_layers) |
| 56 | ], |
| 57 | norm_layer=torch.nn.LayerNorm(configs.d_model) |
| 58 | ) |
| 59 | # Decoder |
| 60 | self.decoder = Decoder( |
| 61 | [ |
| 62 | DecoderLayer( |
| 63 | AttentionLayer( |
| 64 | FullAttention(True, configs.factor, attention_dropout=configs.dropout, output_attention=False), |
| 65 | configs.d_model, configs.n_heads), |
| 66 | AttentionLayer( |
| 67 | FullAttention(False, configs.factor, attention_dropout=configs.dropout, output_attention=False), |
| 68 | configs.d_model, configs.n_heads), |
| 69 | configs.d_model, |
| 70 | configs.d_ff, |
| 71 | dropout=configs.dropout, |
| 72 | activation=configs.activation, |
| 73 | ) |
| 74 | for l in range(configs.d_layers) |
| 75 | ], |
| 76 | norm_layer=torch.nn.LayerNorm(configs.d_model), |
| 77 | projection=nn.Linear(configs.d_model, configs.c_out, bias=True) |
| 78 | ) |
| 79 | |
| 80 | def forward(self, x_enc, x_mark_enc, x_dec, x_mark_dec, |
| 81 | enc_self_mask=None, dec_self_mask=None, dec_enc_mask=None): |
nothing calls this directly
no test coverage detected