-
Notifications
You must be signed in to change notification settings - Fork 479
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
Fixes for Boolean Input Tensors #666
Conversation
@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the fix and test cases!
else: | ||
binary_mask = tuple( | ||
curr_sample[0][feature_mask[j]] for j in range(len(feature_mask)) | ||
curr_sample[0][feature_mask[j]].bool() for j in range(len(feature_mask)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to inputs being boolean or is it so that we can use ~
operator ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is necessary since if this mask is an int / float, multiplying by a boolean still casts product to int / float causing the masked input to not be a boolean.
) | ||
|
||
def test_simple_shapley_sampling_boolean_with_baseline(self) -> None: | ||
net = BasicModelBoolInput() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way of testing would be using BasicModel_MultiLayer()
with the transformed input and seeing if we get the same result but if we manually verified expected value, then it looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I double checked the values manually, they seem correct.
This adds support for boolean input tensors to perturbation-based methods (Shapley Value Sampling and Lime) with corresponding unit tests.