Skip to content

Commit

Permalink
Use pin_memory=True, shuffle=True and num_workers=0 by default (#…
Browse files Browse the repository at this point in the history
…701)

* Use num_workers=0 by default

* Use pin_memory=True by default

* Use shuffle=True by default

* Update CHANGELOG

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
akihironitta and mergify[bot] authored Aug 13, 2021
1 parent fb558d1 commit 2d7ae88
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Changed the default values `pin_memory=False`, `shuffle=False` and `num_workers=16` to `pin_memory=True`, `shuffle=True` and `num_workers=0` of datamodules ([#701](https://github.com/PyTorchLightning/lightning-bolts/pull/701))


### Deprecated

Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/binary_mnist_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: Union[int, float] = 0.2,
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
8 changes: 4 additions & 4 deletions pl_bolts/datamodules/cifar10_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: Union[int, float] = 0.2,
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: int = 50,
num_workers: int = 16,
num_workers: int = 0,
num_samples: int = 100,
labels: Optional[Sequence] = (1, 5, 8),
*args: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/cityscapes_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def __init__(
data_dir: str,
quality_mode: str = 'fine',
target_type: str = 'instance',
num_workers: int = 16,
num_workers: int = 0,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/fashion_mnist_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: Union[int, float] = 0.2,
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/imagenet_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def __init__(
meta_dir: Optional[str] = None,
num_imgs_per_val_class: int = 50,
image_size: int = 224,
num_workers: int = 16,
num_workers: int = 0,
batch_size: int = 32,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/kitti_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def __init__(
data_dir: Optional[str] = None,
val_split: float = 0.2,
test_split: float = 0.1,
num_workers: int = 16,
num_workers: int = 0,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/mnist_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: Union[int, float] = 0.2,
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
4 changes: 2 additions & 2 deletions pl_bolts/datamodules/sklearn_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def __init__(
y_test=None,
val_split=0.2,
test_split=0.1,
num_workers=2,
num_workers=0,
random_state=1234,
shuffle=True,
batch_size: int = 16,
pin_memory=False,
pin_memory=True,
drop_last=False,
*args,
**kwargs,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/ssl_imagenet_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def __init__(
self,
data_dir: str,
meta_dir: Optional[str] = None,
num_workers: int = 16,
num_workers: int = 0,
batch_size: int = 32,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/stl10_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def __init__(
data_dir: Optional[str] = None,
unlabeled_val_split: int = 5000,
train_val_split: int = 500,
num_workers: int = 16,
num_workers: int = 0,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/vision_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def __init__(
self,
data_dir: Optional[str] = None,
val_split: Union[int, float] = 0.2,
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down
6 changes: 3 additions & 3 deletions pl_bolts/datamodules/vocdetection_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def __init__(
self,
data_dir: str,
year: str = "2012",
num_workers: int = 16,
num_workers: int = 0,
normalize: bool = False,
shuffle: bool = False,
pin_memory: bool = False,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
*args: Any,
**kwargs: Any,
Expand Down

0 comments on commit 2d7ae88

Please sign in to comment.