Skip to content

Commit

Permalink
fixed subsampling for ddp training
Browse files Browse the repository at this point in the history
  • Loading branch information
z-fabian committed Aug 13, 2020
1 parent 2b442ad commit 560e583
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fastmri/data/mri_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class SliceDataset(Dataset):
what fraction of the volumes should be loaded.
"""

def __init__(self, root, transform, challenge, sample_rate=1):
def __init__(self, root, transform, challenge, sample_rate=1, seed=0):
if challenge not in ("singlecoil", "multicoil"):
raise ValueError('challenge should be either "singlecoil" or "multicoil"')

Expand All @@ -126,6 +126,7 @@ def __init__(self, root, transform, challenge, sample_rate=1):

files = list(pathlib.Path(root).iterdir())
if sample_rate < 1:
random.seed(seed) # get the same files in every process
random.shuffle(files)
num_files = round(len(files) * sample_rate)
files = files[:num_files]
Expand Down

0 comments on commit 560e583

Please sign in to comment.