GradientTape¶
- class
dragon.vm.tensorflow.
GradientTape
(persistent=False)[source]¶ Record the operations for auto differentiation.
You should enter a tape before the execution performed:
with dragon.eager_mode(): x = tf.ones(shape=(2, 3)) with tf.GradientTape() as tape: y = x + 1 print(tape.gradient(y, x)) # None, as ``x`` is not watched with tf.GradientTape() as tape: tape.watch(x) y = x + 1 print(tape.gradient(y, x)) # Ok