I've noticed that on subsequent runs of a Tensorflow script, your graph Ops get numbered names for example:
loss = tf.reduce_mean(tf.nn.l2_loss(y - pred), name="l2_loss")
would get the names:
l2_loss
l2_loss_1
l2_loss_2
...
l2_loss_N
as you continue to make the same runs in the same IPython session. This wouldn't be so annoying, except that later in scripts when you want to save a summary:
x_sample, y_sample = get_sample(X, Y)
feed = {x: x_batch, y: y_batch}
trainer.run(feed_dict=feed)
summary_str = summary_op.eval(feed_dict=feed)
you'll get the following failure:
InvalidArgumentError: You must feed a value for placeholder tensor 'x_input' with dtype float ....
Is there a way to (at the top of a script or something) to void all these old, out-of-date Op definitions and use the current run and correctly obey the name=...
imperative when creating variables, placeholders, and constants?
To your follow-up question, you might be getting the AssertionError
due to redefining your interactive session.
sess = InteractiveSession()
sess = InteractiveSession()
Exception AssertionError: AssertionError("Nesting violated for default stack of <type 'weakref'> objects") in ...
You can avoid this by closing the session first, sess.close()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With