Skip to content

Instantly share code, notes, and snippets.

@shayaf84
Last active November 20, 2021 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shayaf84/d45e4b06f2d77710c2cff7c5abc76c2e to your computer and use it in GitHub Desktop.
Save shayaf84/d45e4b06f2d77710c2cff7c5abc76c2e to your computer and use it in GitHub Desktop.
def integralEstimates(gradients):
# riemann_trapezoidal
grads = (gradients[:-1] + gradients[1:]) / tf.constant(2.0)
integrated_gradients = tf.math.reduce_mean(grads, axis=0)
return integrated_gradients
integ = integralEstimates(gradients=computedGradients)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment