tensorflow: Tutorial has error: Recurrent Neural Networks

Tutorial URL: https://www.tensorflow.org/tutorials/recurrent I’m going through the tutorial listed above and I think there is a mistake in the very first code example:

lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)
# Initial state of the LSTM memory.
state = tf.zeros([batch_size, lstm.state_size])

An error is reported for the third line:

ValueError: setting an array element with a sequence.

If one prints the lstm.state_size object (where say, lstm_size = 50) one finds:

LSTMStateTuple(c=50, h=50)

I’m guessing this should be:

lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)
# Initial state of the LSTM memory.
state = tf.zeros([batch_size, lstm_size])

But frankly there are numerous other errors in this tutorial as well, so I’m not sure. I will continue to report them as I find them. Version: tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl Running on Ubuntu 14.04

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 38 (13 by maintainers)

Most upvoted comments

While this tutorial is just a little outdated (they still point to RNNCells in tf.nn.rnn_cell instead of tf.contrib.rnn), a lot of the examples are still very good:

http://www.wildml.com/2016/08/rnns-in-tensorflow-a-practical-guide-and-undocumented-features/

On Tue, Apr 18, 2017 at 2:42 PM, Kevin Shaw notifications@github.com wrote:

@ebrevdo https://github.com/ebrevdo : could we get a short snippet of sample code using tf.nn.dynamic_rnn? 😃

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tensorflow/issues/9294#issuecomment-294991817, or mute the thread https://github.com/notifications/unsubscribe-auth/ABtim-CBYbG8zxpfR9DY5P_NHWDo-HxPks5rxS43gaJpZM4NAvZe .

You don’t. We should really change the tutorial to use tf.nn.dynamic_rnn – which handles most of this for you.

On Tue, Apr 18, 2017 at 2:28 PM, Kevin Shaw notifications@github.com wrote:

@Engineero https://github.com/Engineero : Here is a dumb question that you may be able to help with. If TF is capable of auto-unrolling LSTMs, then why do we need to use the for loop (in the sample above) to feed in the words one at a time? I’ve never understood this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tensorflow/issues/9294#issuecomment-294987951, or mute the thread https://github.com/notifications/unsubscribe-auth/ABtim4IAH-RQE3--SUoWa8SY301zh6GEks5rxSsagaJpZM4NAvZe .

@kevinashaw Did you finally find a solution for the linear problem?

ValueError: linear is expecting 2D arguments: [TensorShape([Dimension(1000)]), 
TensorShape([Dimension(1000), Dimension(50)])]

@kevinashaw that’s where I am now too. It seems like we are not presenting arguments to the __call__ method of lstm correctly. I am working a different problem, but same issue.