You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the @tf.function allows the function to be precompiled. Since it is compiled, it runs faster
tensorspec basically allows us to pre define the shapes of specific arrays as we are pre compiling it
call
here we are trying to find the gradients of the image
this method is called gradient ascent. This adds the gradients found in every layer to the image and thus increases the activations at that point as well which is what we want
GradientTape allows us to keep a sort of history of all the gradients and allows us to use it to calculate loss directly from the history
After we get the gradients, we normalize them
img = img + gradients * step_size is the main ascent function which maximizes the loss
the clip value function here is used to scale all numbers to -1 or 1. Any values less than -1 is set to 1 and greater than 1 is set to 1. (You can say its another form of normalization)