Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-176

Integrated Gradients Step

Problem

Evaluate one integrand term of integrated gradients: (x - baseline) * grad, where grad is the gradient of the model output at one interpolation point between the baseline and the input.

The signature is integrated_gradients_step(x, baseline, grad). Return the element-wise product.

Hint

The full attribution averages this term over many points along the path from baseline to input.

Test cases

case 1
in: [[1,2],[0,0],[0.5,0.5]]
expected: [0.5,1]
case 2
in: [[1,1],[1,1],[5,5]]
expected: [0,0]
case 3
in: [[3,0],[-1,0],[2,-2]]
expected: [8,0]
case 4
in: [[0.5],[0],[1]]
expected: [0.5]
Starter codePython
def integrated_gradients_step(x, baseline, grad):
    # Your code here
    pass

4 test cases · run your code against them in the editor