TensorFlow dynamic_rnn regressor: ValueError dimension mismatch

佐手、 提交于 2019-12-03 14:57:48

As discussed in the comments, the tf.nn.dynamic_rnn(cell, inputs, ...) function expects a list of three-dimensional tensors* as its inputs argument, where the dimensions are interpreted by default as batch_size x num_timesteps x num_features. (If you pass time_major=True, they are interpreted as num_timesteps x batch_size x num_features.) Therefore the preprocessing you've done in the original placeholder is unnecessary, and you can pass the oriding X value directly to tf.nn.dynamic_rnn().


* Technically it can accept complicated nested structures in addition to lists, but the leaf elements must be three-dimensional tensors.**

** Investigating this turned up a bug in the implementation of tf.nn.dynamic_rnn(). In principle, it should be sufficient for the inputs to have at least two dimensions, but the time_major=False path assumes that they have exactly three dimensions when it transposes the input into the time-major form, and it was the error message that this bug inadvertently causes that showed up in your program. We're working on getting that fixed.

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