Inputs are not sequence wth RNN and TensorFlow

I have a very simple lstm code with tensorflow and python where my code is

output = tf.nn.rnn(tf.nn.rnn_cell.BasicLSTMCell(10), input_flattened, initial_state=tf.placeholder("float", [None, 20]))

where my smoothed input is form [?, 5, 22501]

I am getting an error TypeError: inputs must be a sequence

on the state

lstm parameter and I am ripping my hair out trying to figure out why it is giving me this error. Any help would be greatly appreciated.

+1


source to share


1 answer


I think that when you use the tf.nn.rnn function it expects a list of tensors, not just one tensor. You have to unpack the input in the time direction so that it is a list of tensors of the form [?, 22501]. You can also use tf.nn.dynamic_rnn which I think can handle this unpacking for you.



+4


source







All Articles