DeepLearning[GradientTape]
Enter
enter a GradientTape context
Exit
exit a GradientTape context
Calling Sequence
Parameters
Description
Details
Examples
Compatibility
Enter( gt )
Exit( gt )
gt
-
a GradientTape object
Enter(gt) enters the context of the GradientTape gt. All operations on watched Tensors or Variables from this point onwards will be recorded in gt for the purposes of computing derivatives.
Exit(gt) exits the context of the GradientTape gt. Recording of operations on watched Tensors or Variables ceases.
Note: It is very important to remember to invoke Exit(gt) even when an error has occurred. A useful pattern is to invoke Enter within an try clause and include Exit in the associated finally clause to ensure it is always executed.
The implementations of Enter and Exit use the similarly named methods from tf.GradientTape in the TensorFlow Python API. Consult the TensorFlow Python API documentation for tf.GradientTape for more information.
Create a GradientTape object, enter its context and compute gradients
with⁡DeepLearning:
tape≔GradientTape⁡
tape≔DeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7f06ec38a9d0>
Enter⁡tape
DeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7f06ec38a9d0>
x≔Constant⁡1.0,2.0
x≔DeepLearning TensorShape: [2]Data Type: float[4]
tape:-Watch⁡x
y≔x2
y≔DeepLearning TensorShape: [2]Data Type: float[4]
J≔tape:-Jacobian⁡y,x
J≔DeepLearning TensorShape: [2, 2]Data Type: float[4]
Exit⁡tape
convert⁡J,Matrix
2.0.0.4.
The DeepLearning[GradientTape][Enter] and DeepLearning[GradientTape][Exit] commands were introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
See Also
DeepLearning Overview
GradientTape
Download Help Document