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
withDeepLearning:
tape≔GradientTape
tape≔DeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7a799563f610>
Entertape
DeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7a799563f610>
x≔Constant1.0,2.0
x≔DeepLearning TensorShape: [2]Data Type: float[4]
tape:-Watchx
y≔x2
y≔DeepLearning TensorShape: [2]Data Type: float[4]
J≔tape:-Jacobiany,x
J≔DeepLearning TensorShape: [2, 2]Data Type: float[4]
Exittape
convertJ,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