这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@dantp-ai
Copy link
Contributor

@dantp-ai dantp-ai commented Aug 2, 2024

Fixes: #1182

Note: Updated test_batch.test_slice_distribution() to use allclose (See: #1181).

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx! I guess it was failing randomly, right?

Copy link
Contributor Author

@dantp-ai dantp-ai Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Thx for the PR! All looks good, merging now

@MischaPanch MischaPanch merged commit a006e7c into thu-ml:master Aug 2, 2024
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.

Make Batch.__eq__ work also for scalar values (0-dimensional arrays)

2 participants