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

Added shuffling to trainset dataloaders, no shuffle by default for ot… #234

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion casanovo/denovo/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def _make_loader(
self,
dataset: torch.utils.data.Dataset,
batch_size: int,
shuffle: bool = False,
) -> torch.utils.data.DataLoader:
"""
Create a PyTorch DataLoader.
Expand All @@ -136,6 +137,8 @@ def _make_loader(
A PyTorch Dataset.
batch_size : int
The batch size to use.
shuffle : bool
Option to shuffle the batches.

Returns
-------
Expand All @@ -148,11 +151,14 @@ def _make_loader(
collate_fn=prepare_batch,
pin_memory=True,
num_workers=self.n_workers,
shuffle=shuffle,
)

def train_dataloader(self) -> torch.utils.data.DataLoader:
"""Get the training DataLoader."""
return self._make_loader(self.train_dataset, self.train_batch_size)
return self._make_loader(
self.train_dataset, self.train_batch_size, shuffle=True
)

def val_dataloader(self) -> torch.utils.data.DataLoader:
"""Get the validation DataLoader."""
Expand Down
Loading