Created
November 7, 2022 11:59
-
-
Save MohanaRC/d19b4d8f348d2834b8569fc077ce15f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tf_gradient_tape(x): | |
""" | |
Simple implementation to understand the functioning of gradient tape | |
Inputs: | |
x: Tensor value | |
Returns: | |
EagerTensor: Derivative of y with respect to input tensor x | |
""" | |
with tf.GradientTape() as t: | |
t.watch(x) | |
y = x**3 ## Defining f(x)=x**2 | |
# Calculating the derivative of y with respect to x | |
dy_dx = t.gradient(y, x) | |
return dy_dx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment