Bugfix/batch eq for scalar#1186
Merged
MischaPanch merged 4 commits intothu-ml:masterfrom Aug 2, 2024
Merged
Conversation
* Seems that batch slicing leads to slightly different floats some of the time (See: thu-ml#1181)
…-ai/tianshou into bugfix/batch_eq_for_scalar
MischaPanch
reviewed
Aug 2, 2024
| assert ( | ||
| Categorical(probs=sliced_probs).probs == get_sliced_dist(dist, selected_idx).probs | ||
| ).all() | ||
| assert torch.allclose(sliced_batch.dist.probs, Categorical(probs=sliced_probs).probs) |
Collaborator
There was a problem hiding this comment.
Thx! I guess it was failing randomly, right?
Contributor
Author
There was a problem hiding this comment.
Yes, it was sporadically returning inequality. I will take a look at getitem soon as I have an overdue task there with maintaining slicing consistency. Then I can also check what causes slicing to make these little decimal errors.
Collaborator
There was a problem hiding this comment.
Thanks, appreciate it! I don't think the getitem issue can actually be solved, but implementing eq already solves all practical problems of it. So no need to further address it, unless you see some simple way for doing that.
The order of slicing however it's still a valid issue
MischaPanch
approved these changes
Aug 2, 2024
Collaborator
|
Thx for the PR! All looks good, merging now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1182
Note: Updated
test_batch.test_slice_distribution()to use allclose (See: #1181).