Dataloaders¶
NOTE: This module should contain custom dataloaders
that the user might want to implement. At the moment pytorch-widedeep
offers one custom dataloader, DataLoaderImbalanced
.
DataLoaderImbalanced ¶
DataLoaderImbalanced(dataset, batch_size, num_workers, **kwargs)
Bases: DataLoader
Class to load and shuffle batches with adjusted weights for imbalanced datasets. If the classes do not begin from 0 remapping is necessary. See here.
Parameters:
-
dataset
(WideDeepDataset
) –see
pytorch_widedeep.training._wd_dataset
-
batch_size
(int
) –size of batch
-
num_workers
(int
) –number of workers
Other Parameters:
-
**kwargs
–This can include any parameter that can be passed to the 'standard' pytorch DataLoader and that is not already explicitely passed to the class. In addition, the dictionary can also include the extra parameter
oversample_mul
which will multiply the number of samples of the minority class to be sampled by theWeightedRandomSampler
.In other words, the
num_samples
param inWeightedRandomSampler
will be defined as:\[ minority \space class \space count \times number \space of \space classes \times oversample\_mul \]
Source code in pytorch_widedeep/dataloaders.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|