Skip to content Skip to sidebar Skip to footer

Why This Tensorflow Tutorial Code Not Working

Now i'm trying lstm tutorial, look some one's book. But it didn't work. What's the problem? : import tensorflow as tf import numpy as np from tensorflow.contrib import rnn impor

Solution 1:

You haven't initialized some graph variables, as the error mentioned. Shift your code to this and it will work.

outputs, _states = tf.nn.dynamic_rnn(cell, x_data, dtype=tf.float32)
init=tf.global_variables_initializer()
sess.run(init)

Best practice is to have init right at the end of your graph and before sess.run.

EDIT: Refer to What does tf.global_variables_initializer() do under the hood? for more insights.

Solution 2:

You define the operation init before creating your variables. Thus this operation will be performed only on the variables defined at that time, even if you run it after creating your variables.

So just move the definition of init and you will be fine.

Post a Comment for "Why This Tensorflow Tutorial Code Not Working"