0

I have a block that creates an LSTM Model for me. I want to iterate on this block and every time pass a new data to it as an arg. but it raises this error :

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

I googled it and I found out that by resetting the model by using this piece of code at the beginning of the block I can solve the error:

tf.reset_default_graph()

but it raises another error:

ValueError: Tensor("lstm/rnn/Const:0", shape=(1,), dtype=int32) must be from the same graph as Tensor("ExpandDims:0", shape=(1,), dtype=int32).

what should I do now? thanks a lot

desertnaut
  • 57,590
  • 26
  • 140
  • 166
MMRA
  • 337
  • 1
  • 3
  • 11
  • did you check [this](https://stackoverflow.com/questions/42616625/valueerror-tensor-must-be-from-the-same-graph-as-tensor-with-bidirectinal-rnn-i)? – skrubber Jul 25 '18 at 18:13
  • yes I didn't use "with tf.Graph().as_default()" @skrubber – MMRA Jul 25 '18 at 18:49
  • You should use different name args within the loop. Or are we talking about [Keras](https://stackoverflow.com/questions/51167542/tensorflow-creating-new-variables-despite-reuse-set-to-true/51167774#51167774)? Why not providing a [mcve]? – Patwie Jul 25 '18 at 20:06

0 Answers0