Your second LSTM layer also returns sequences and Dense layers by default apply the kernel to every timestep also producing a sequence:
# (bs, 45, 2)
model.add( LSTM( 512, input_shape=(45, 2), return_sequences=True))
# (bs, 45, 512)
model.add( LSTM( 512, return_sequences=True))
# (bs, 45, 512)
model.add( (Dense(1)))
# (bs, 45, 1)
So your output is shape (bs, 45, 1)
. To solve the problem you need to set return_sequences=False
in your second LSTM layer which will compress sequence:
# (bs, 45, 2)
model.add( LSTM( 512, input_shape=(45, 2), return_sequences=True))
# (bs, 45, 512)
model.add( LSTM( 512, return_sequences=False)) # SET HERE
# (bs, 512)
model.add( (Dense(1)))
# (bs, 1)
And you'll get the desired output. Note bs
is the batch size.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…