wzhwzhwzh0921 / S-D-Mamba

Code for "Is Mamba Effective for Time Series Forecasting?"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about how to implement the reverse Mamba in your code

packer-c opened this issue · comments

Thank you for your nice paper and sharing code.

I'm a little confused on how you implemented the reverse Mamba part in your code.
In ./model/S_Mamba.py, I saw that in lines 92~94, input two of "x_enc" and "x_mark_enc". What does “x_mark_enc” mean (is it related to the reverse)?

    def forward(self, x_enc, x_mark_enc, x_dec, x_mark_dec, mask=None):
        dec_out = self.forecast(x_enc, x_mark_enc, x_dec, x_mark_dec)
        return dec_out[:, -self.pred_len:, :]

Thanks in advance for the clarification!

It's not related to reverse. I think they are some additional variates about time ( I'm not sure and i just followed the settings of the former opensource code. )

Thank you for your reply.

So, which part of the code is the reversed Mamba process mentioned in your update paper (I mean Mamba VC reversed part at Figure 2).
I saw that there are two parallel Mambas in ./model/S_Mamba.py, but they both seem to be forward?

self.encoder = Encoder(
            [
                EncoderLayer(
                        Mamba(
                            d_model=configs.d_model,  # Model dimension d_model
                            d_state=configs.d_state,  # SSM state expansion factor
                            d_conv=2,  # Local convolution width
                            expand=1,  # Block expansion factor)
                        ),
                        Mamba(
                            d_model=configs.d_model,  # Model dimension d_model
                            d_state=configs.d_state,  # SSM state expansion factor
                            d_conv=2,  # Local convolution width
                            expand=1,  # Block expansion factor)
                        ),
                    configs.d_model,
                    configs.d_ff,
                    dropout=configs.dropout,
                    activation=configs.activation
                ) for l in range(configs.e_layers)
            ],
            norm_layer=torch.nn.LayerNorm(configs.d_model)
        )

Could you clarify how to implement the reverse Mamba part? Thanks!

You can check line 22 in Mamba_EncDec.py.

Reverse the input of Mamba (the variates sequence) and use another Mamba block to process it.

Got it. Great!