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

RandomGeoSampler: several bug fixes #477

Merged
merged 3 commits into from
Apr 5, 2022
Merged

RandomGeoSampler: several bug fixes #477

merged 3 commits into from
Apr 5, 2022

Conversation

adamjstewart
Copy link
Collaborator

This PR includes the following fixes:

  • Sample from tiles with larger areas more often (fixes RandomGeoSampler bias #408)
  • Allow size=0 queries to handle point data
  • Allow size=(height, width) queries for entire tile at a time
  • Use PyTorch's built-in random sampling for easier seed setting

The first requires #375 so has to be in 0.3.0. The rest could theoretically be backported to 0.2.2 but I'm not really planning on a 0.2.2 release at the moment.

@adamjstewart adamjstewart added this to the 0.3.0 milestone Mar 22, 2022
@github-actions github-actions bot added samplers Samplers for indexing datasets testing Continuous integration testing labels Mar 22, 2022
# Choose a random tile
hit = random.choice(self.hits)
# Choose a random tile, weighted by area
idx = torch.multinomial(self.areas, 1)
Copy link
Member

@calebrob6 calebrob6 Mar 30, 2022

Choose a reason for hiding this comment

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

this defaults to sampling without replacement -- is that the intention here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We only sample a single idx at a time so replacement wouldn't affect anything.

@calebrob6 calebrob6 merged commit f262b00 into main Apr 5, 2022
@calebrob6 calebrob6 deleted the samplers/area-bias branch April 5, 2022 16:48
remtav pushed a commit to remtav/torchgeo that referenced this pull request May 26, 2022
* RandomGeoSampler: prevent area bias

* Use builtin PyTorch random

Co-authored-by: Caleb Robinson <calebrob6@gmail.com>
@adamjstewart adamjstewart mentioned this pull request Jul 11, 2022
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* RandomGeoSampler: prevent area bias

* Use builtin PyTorch random

Co-authored-by: Caleb Robinson <calebrob6@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samplers Samplers for indexing datasets testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RandomGeoSampler bias
2 participants