Last active
November 20, 2021 16:08
-
-
Save shayaf84/577277b5717e03d2805cc8a2cd221dcd 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 gradient(images, targetClassindex): | |
#Computes gradient of probabilities with respect to images | |
with tf.GradientTape() as gradRecord: | |
gradRecord.watch(images) | |
logits = vgg(images) | |
probs = tf.nn.softmax(logits, axis=-1)[:, targetClassindex] | |
return gradRecord.gradient(probs, images) | |
computedGradients = gradient(interpolatedImages,684) | |
#ImageNet Index for Oboe is 683, so add 1 to receive the value to stop at. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment