Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tf.gradients with tf.GradientTape : RuntimeError #69

Closed
shahmanan5811 opened this issue Aug 28, 2020 · 2 comments
Closed

Replace tf.gradients with tf.GradientTape : RuntimeError #69

shahmanan5811 opened this issue Aug 28, 2020 · 2 comments

Comments

@shahmanan5811
Copy link

shahmanan5811 commented Aug 28, 2020

Traceback (most recent call last):
File "Neural-Style-Transfer/INetwork.py", line 524, in
grads = K.gradients(loss, combination_image)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py", line 3969, in gradients
loss, variables, colocate_gradients_with_ops=True)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gradients_impl.py", line 172, in gradients
unconnected_gradients)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gradients_util.py", line 491, in _GradientsHelper
raise RuntimeError("tf.gradients is not supported when eager execution "
RuntimeError: tf.gradients is not supported when eager execution is enabled. Use tf.GradientTape instead.

@shahmanan5811 shahmanan5811 changed the title tf.gradients is not supported when eager execution is enabled. Use tf.GradientTape instead. Replace tf.gradients with tf.GradientTape. Aug 28, 2020
@shahmanan5811 shahmanan5811 changed the title Replace tf.gradients with tf.GradientTape. Replace tf.gradients with tf.GradientTape : RuntimeError Aug 28, 2020
@shahmanan5811 shahmanan5811 reopened this Aug 28, 2020
@bomtorazek
Copy link

Firstly, import tensorflow as tf

Next, just type the following snippet.

tf.compat.v1.disable_eager_execution()

@MentalGear
Copy link

MentalGear commented Oct 3, 2020

You got to add
%tensorflow_version 1.x
colab now uses TF 2 by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants