-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when there are many input features ,how to use the IntegratedGradients? #1312
Comments
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. |
Hi @khairulislam, I have the same problem with this bro and I don't know how to utilize this code for multi-inputs. For example, if I have four different inputs for the model. Is it the code should be like this? '''ig = IntegratedGradients(model) But it reports that "AttributeError: 'tuple' object has no attribute 'shape'" |
Hi @phet1999 , try interpreting one input at a time. Then add the returned interpretations in a tuple. You could have a variable inside the model class to set which input no is being passed. Then the default call method will arrange them 1-4 and call the original call method. the gradient calculation is w.r.t one input only, hence it won't directly support multiple inputs.
|
Hi @khairulislam, thank you for your replying, but problems still exist. Then, I want to get the attribution of the first input feature but it still comes with a problem that |
Hi, @khairulislam. I am sorry for bothering and I tried another method that sets
and inside forward function, it acts like this
In this situation, there is just one input in the forward function. But the problem is still not solved for this code
It said that RuntimeError: Sizes of tensors must match except in dimension 2. Expected size 1000 but got size 20 for tensor number 1 in the list. It seems that the code repeats my input 50 times at the batch channel(the same as the number of parameters n_steps, and when I set it to 1, the problem is 'AttributeError: 'tuple' object has no attribute 'shape'') |
❓ 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?
The text was updated successfully, but these errors were encountered: