问题
I have some very basic 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 input flattened is shape [?, 5, 22501]
I'm getting the error TypeError: inputs must be a sequence
on the state
parameter of the lstm, and I'm ripping my hair out trying to find out why it is giving me this error. Any help would be greatly appreciated.
回答1:
I think when you use the tf.nn.rnn function it is expecting a list of tensors and not just a single tensor. You should unpack input in the time direction so that it is a list of tensors of shape [?, 22501]. You could also use tf.nn.dynamic_rnn which I think can handle this unpack for you.
来源:https://stackoverflow.com/questions/38728501/inputs-not-a-sequence-wth-rnns-and-tensorflow