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

Fix/methods #85

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions oodeel/datasets/ooddataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def prepare(
with_ood_labels: bool = False,
with_labels: bool = True,
shuffle: bool = False,
shuffle_buffer_size: Optional[int] = None,
**kwargs_prepare,
) -> DatasetType:
"""Prepare self.data for scoring or training

Expand All @@ -282,9 +282,9 @@ def prepare(
Defaults to True.
shuffle (bool, optional): To shuffle the returned dataset or not.
Defaults to False.
shuffle_buffer_size (int, optional): (TF only) Size of the shuffle buffer.
If None, taken as the number of samples in the dataset.
Defaults to None.
kwargs_prepare (dict): Additional parameters to be passed to the
data_handler.prepare_for_training method.
Comment on lines +285 to +286
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion: we could extend this docstring with examples of usage, like "e.g. shuffle_buffer_size for TF data handler or num_workers for torch handler."

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point



Returns:
DatasetType: prepared dataset
Expand Down Expand Up @@ -323,7 +323,7 @@ def prepare(
preprocess_fn=preprocess_fn,
augment_fn=augment_fn,
output_keys=keys,
shuffle_buffer_size=shuffle_buffer_size,
**kwargs_prepare,
)

return dataset
3 changes: 3 additions & 0 deletions oodeel/datasets/torch_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ def prepare_for_training(
output_keys: Optional[list] = None,
dict_based_fns: bool = False,
shuffle_buffer_size: Optional[int] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this line must be removed, since there is now kwargs_prepare?

num_workers: int = 8,
) -> DataLoader:
"""Prepare a DataLoader for training

Expand All @@ -587,6 +588,7 @@ def prepare_for_training(
shuffle_buffer_size (int, optional): Size of the shuffle buffer. Not used
in torch because we only rely on Map-Style datasets. Still as argument
for API consistency. Defaults to None.
num_workers (int, optional): Number of workers to use for the dataloader.

Returns:
DataLoader: dataloader
Expand Down Expand Up @@ -621,6 +623,7 @@ def collate_fn(batch: List[dict]):
batch_size=batch_size,
shuffle=shuffle,
collate_fn=collate_fn,
num_workers=num_workers,
)
return loader

Expand Down