pytorch / captum

Model interpretability and understanding for PyTorch
https://captum.ai
BSD 3-Clause "New" or "Revised" License
4.96k stars 499 forks source link

when there are many input features ,how to use the IntegratedGradients? #1312

Open Sarah-air opened 4 months ago

Sarah-air commented 4 months ago

❓ Questions and Help

the classification model is classification_pred = model([input_x[0], input_x[1],input_x[2], input_x[3]], os_event.size(0),
 {'gex': 0, 'methy': 1, 'mut':2, 'cna': 3}),the input_x of one sample is as the figure showed,how to use the IntegratedGradients to get the four features' attribution?image

khairulislam commented 3 months ago

Hi @Sarah-air , if your model uses all 4 inputs, then normal passing is fine. but if it doesn't, you'll have to pass only the inputs that your model uses to the attribute method as input and the rest as additional forward args. The Gradient method throws an error if any input is unused. Check our example here.