TimeDistributed with different input / output sequence length I'm looking into using TimeDistributed in my LSTM to see if it would improve the accuracy of my model.  I'll be honest, I'm still not 100% sure what the specific use case for TimeDistributed, I just thought I'd give it a try and see if it improved my accuracy. Aside from blind trial/error, why would someone use TimeDistributed?

Now, my next question is probably tied to my lack of understanding of exactly what TimeDistributed's specific use case is, but I understand that the output from TimeDistributed is a sequence, and that sequence is the same length as the input sequence because you use return_sequences=True on the final layer of the model (all of them in my case, as it's stateful).

In my case I'm inputting a sequence which is 100 length, and I'm then forecasting a sequence of length 3 from that input sequence, but I get this error:


  Error when checking target: expected time_distributed_1 to have shape
  (100, 3) but got array with shape (3, 1)


Am I right in assuming that you can only use TimeDistributed if your output sequence is the same length as the input sequence?

Many thanks
I have looked for an answer to this question for quite a while, and couldn't really find a clear yes/no answer.

From what I understand, TimeDistributed really only works for similar input/output lengths. 
According to what Jason Brownlee writes in the comments section of his TimeDistributed tutorial, he would treat the different input/output lengths as a seq2seq/encoder-decoder problem (which he describes here). 

If you find a better answer, or find a way to make TimeDistributed work with different output sizes, please let me know.



*Update (copying my comment from below, with better formatting):

Actually, I have found a different solution which does use TimeDistributed: You can trim the output sequence you get from TimeDistributed using Cropping1D layer. So that my model now looks like this: 

model.add(LSTM(hidden_size, return_sequences=True, input_shape=(num_input_timepoints, 1) ,dropout=0.05)
model.add(TimeDistributed(Dense(1))) 
model.add(Cropping1D(cropping=(num_input_timepoints - num_output_timepoints,0))) # cropping the end 


Which, in your case, would trim the first 97 time points and would leave you with the last 3. That would fit the shape of your target data.