Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k points)

Any ideas of how can I solve the problem shown below? With the information that I found on the web, it is associated with the problem of reusing tensorflow scope however nothing works.

ValueError: Variable rnn/basic_rnn_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

  File "/code/backend/management/commands/RNN.py", line 370, in predict

    states_series, current_state = tf.nn.dynamic_rnn(cell=cell, inputs=batchX_placeholder, dtype=tf.float32)

  File "/code/backend/management/commands/RNN.py", line 499, in Command

    predict("string")

  File "/code/backend/management/commands/RNN.py", line 12, in <module>

    class Command(BaseCommand):

I tried, for instance, something like this

with tf.variable_scope('scope'):

 states_series, current_state = tf.nn.dynamic_rnn(cell=cell, inputs=batchX_placeholder, dtype=tf.float32)

and this

with tf.variable_scope('scope', reuse = True ):

 states_series, current_state = tf.nn.dynamic_rnn(cell=cell, inputs=batchX_placeholder, dtype=tf.float32)

and this

with tf.variable_scope('scope', reuse = tf.AUTO_REUSE ):

 states_series, current_state = tf.nn.dynamic_rnn(cell=cell, inputs=batchX_placeholder, dtype=tf.float32)

Any ideas?

1 Answer

0 votes
by (33.1k points)

Simply put this line at the starting of your code:

tf.reset_default_graph()

Hope this answer helps you!

For more details, study Machine Learning Course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...