GradientTape - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DeepLearning

  

GradientTape

  

create gradient tape object

 

Calling Sequence

Parameters

Options

Description

Operations with GradientTapes

Details

Examples

Compatibility

Calling Sequence

GradientTape( opts )

Parameters

opts

-

(optional) options as described below

Options

• 

persistent = truefalse

  

Specifies whether a persistent gradient tape is created.

  

When true, the data is retained until Reset is called or the GradientTape object is garbage-collected.

• 

When false (the default), the data is automatically collected after Gradient or Jacobian is called.

Description

• 

GradientTape builds a gradient tape object to track one or more Tensors or Variables for the purposes of computing gradients.

• 

This function is part of the DeepLearning package, so it can be used in the short form GradientTape(..) only after executing the command with(DeepLearning). However, it can always be accessed through the long form of the command by using DeepLearning[GradientTape](..).

Operations with GradientTapes

• 

The following functions can be performed with a GradientTape.

Details

• 

The implementation of GradientTape uses the tf.GradientTape command from the TensorFlow Python API. Consult the TensorFlow Python API documentation for tf.GradientTape for more information on random number generation during TensorFlow computations.

Examples

Compute a simple gradient of a constant Tensor.

withDeepLearning:

xConstant3.0,5.0

xDeepLearning TensorShape: [2]Data Type: float[4]

(1)

tapeGradientTape

tapeDeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7f6e6e72a050>

(2)

Entertape

DeepLearning GradientTape<tensorflow.python.eager.backprop.GradientTape object at 0x7f6e6e72a050>

(3)

tape:-Watchx

yx2

yDeepLearning TensorShape: [2]Data Type: float[4]

(4)

Exittape

gradtape:-Gradienty&comma;x

gradDeepLearning TensorShape: [2]Data Type: float[4]

(5)

grad

DeepLearning TensorShape: [2]Data Type: float[4]

(6)

Compatibility

• 

The DeepLearning[GradientTape] command was introduced in Maple 2022.

• 

For more information on Maple 2022 changes, see Updates in Maple 2022.

See Also

DeepLearning Overview