Inputs not a sequence wth RNNs and TensorFlow

社会主义新天地 提交于 2020-01-05 05:45:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!