Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

vivekmig
Copy link
Contributor

@vivekmig vivekmig commented May 3, 2021

This adds support for boolean input tensors to perturbation-based methods (Shapley Value Sampling and Lime) with corresponding unit tests.

@facebook-github-bot
Copy link
Contributor

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@NarineK NarineK left a 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))
Copy link
Contributor

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 ?

Copy link
Contributor Author

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()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@facebook-github-bot
Copy link
Contributor

@vivekmig merged this pull request in 152bcfd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants