[solved] Concatenate time distributed CNN with LSTM

Hi, thank you for the code, but I have problem when I tried to implement, my input is (n_sample, n_channel, n_length) for Conv1d, for forward function when I use r_out, hidden = self.rnn(r_in) it will always generate error like this

File “”, line 18, in
output = model(data)

File “C:\Users\User-J\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)

File “C:/Users/User-J/building_framework/idnet_cnn_rnn.py”, line 126, in forward
x, h = self.rnn(x)

File “C:\Users\User-J\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)

File “C:\Users\User-J\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py”, line 178, in forward
self.check_forward_args(input, hx, batch_sizes)

File “C:\Users\User-J\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py”, line 126, in check_forward_args
expected_input_dim, input.dim()))

RuntimeError: input must have 3 dimensions, got 2

I guess because when training the output = model(data) only, is it suppose to be output, _ = model(data,None) but still this can’t get rid of the error, maybe you can help, because I need to use 1d conv and lstm.

Thank you