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.
Baca Juga
- Does Applying A Dropout Layer After The Embedding Layer Have The Same Effect As Applying The Dropout Through The Lstm Dropout Parameter?
- On Training Lstms Efficiently But Well, Parallelism Vs Training Regime
- Why The Model Is Training On Only 1875 Training Set Images If There Are 60000 Images In The Mnist Dataset?
So just move the definition of init and you will be fine.
Post a Comment for "Why This Tensorflow Tutorial Code Not Working"