Skip to content

BUG: MedNISTDataset returns differently sized datasets for different seeds#1761

Merged
wyli merged 2 commits intoProject-MONAI:masterfrom
adamaji:mednist-size
Mar 14, 2021
Merged

BUG: MedNISTDataset returns differently sized datasets for different seeds#1761
wyli merged 2 commits intoProject-MONAI:masterfrom
adamaji:mednist-size

Conversation

@adamaji
Copy link
Copy Markdown
Contributor

@adamaji adamaji commented Mar 13, 2021

Description

Fixes an issue with MedNISTDataset where choosing a different random seed returns a differently sized dataset.
Reproduce by running

data0 = monai.apps.datasets.MedNISTDataset(root_dir="./tmp", transform=[], section="test", download=False, seed=0)
data42 = monai.apps.datasets.MedNISTDataset(root_dir="./tmp", transform=[], section="test", download=False, seed=42)
assert len(data0) != len(data42)

Instead of seeing whether a chosen random value falls between the train/val/test split serially, this PR uses the same kind of implementation for choosing random indices all at once like how it's done in DecathlonDataset.

Also modified the existing MedNIST test to use the full dataset length for comparison and to test dataset lengths for different seeds.

It seems like https://github.com/Project-MONAI/tutorials/blob/master/2d_classification/mednist_tutorial.ipynb may also need these changes.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Mar 14, 2021

/integration-test

Copy link
Copy Markdown
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

thanks!

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Mar 14, 2021

/black

@wyli wyli merged commit 42e963f into Project-MONAI:master Mar 14, 2021
@adamaji adamaji deleted the mednist-size branch March 14, 2021 17:39
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