LSTM return_state=True fail with tf.keras.Sequencial model #36624
Labels
comp:keras
Keras related issues
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
TF 2.1
for tracking issues in 2.1 release
type:bug
Bug
Describe the current behavior
The
call
method of atf.keras.Sequential
object fails and throws an error when one layer is an instance of thetf.keras.layers.LSTM
class constructed withreturn_state=True
. Given the error message, I believe it is because the output of thecall
method of suchLSTM
layer is alist
instead of aTensor
, and thecall
method ofSequential
does not know what to do with alist
.Describe the expected behavior
I think that the
call
method ofSequential
should know that theTensor
output ofLSTM
is the first element of thelist
whenreturn_state=True
.Code to reproduce the issue
Setting :
Output:
Error with
Sequential
:Output:
It works when constructing the model with the Functional API:
Output:
Related question
In my Functional API example,
lstm_model
fails if I useinp = tf.keras.Input(shape=(ts, None))
instead of providing the explicit input dimension. The error message I get is:Is it normal? If so, why is that?
The text was updated successfully, but these errors were encountered: