Skip to content

Set difference1d tensor#9

Open
rishabh-mondal wants to merge 6 commits intosustainability-lab:mainfrom
rishabh-mondal:set_difference1d
Open

Set difference1d tensor#9
rishabh-mondal wants to merge 6 commits intosustainability-lab:mainfrom
rishabh-mondal:set_difference1d

Conversation

@rishabh-mondal
Copy link

Return the elements in a that are not in `b'

a = torch.tensor([1, 2, 3, 4, 5])
b = torch.tensor([3, 4, 6, 7, 8])

result =([1,2,5])
mask = ~a.unsqueeze(1).eq(b).any(dim=1)
Creates a Boolean mask to identify elements in a that are not present in b.

torch.masked_select(a, mask)
torch.masked_select function to select elements from tensor 'a' based on the Boolean mask.

@patel-zeel
Copy link
Member

This PR should change only utils.py. Currently, it changes 3 files in total.

@rishabh-mondal
Copy link
Author

PR is updated please check.

@patel-zeel
Copy link
Member

@rishabh-mondal Rename the function to exactly match with numpy function. Add tests where you use numpy inbuilt function and verify that your function produces the same output. Please add runtime information in this PR as well.

@patel-zeel
Copy link
Member

@rishabh-mondal, can you please do what is needed for this PR?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants