Hi, I am wondering if it is possible to include an IF-ELSE statement in the LSTM part of the code. Here is the section:
        if flag == True:
            print("reconstruction")
            h_t, c_t = self.lstm1(z, (h_t, c_t))
            h_t2, c_t2 = self.lstm2(c_t, (h_t2, c_t2))
        else:
            print("prediction")
            h_t, c_t = self.lstm1(z_null, (h_t, c_t))
            h_t2, c_t2 = self.lstm2(c_t, (h_t2, c_t2))

where z_null is a all-zero vector with the same shape as z.
So what I want to do is that at each time-step, the LSTM could either have an input or only use the information from previous hidden state.
Since PyTorch is a dynamic network tool, I assume it should be able to do this. But during my experiment, seems like the LSTM actually gets the input at each time-step, regardless of the IF-ELSE statement.
Could someone help me with this question? Thanks!