torchtable.loader module

Module contents

class torchtable.loader.DefaultLoader(dataset: torch.utils.data.dataset.Dataset, batch_size: int, device: Optional[torch.device] = None, repeat: bool = False, shuffle: Optional[bool] = None)

Bases: torch.utils.data.dataloader.DataLoader

Defines an iterator that loads batches of data from a Dataset. Heavily based on the Iterator from torchtext.

Parameters:
  • dataset – The Dataset object to load examples from.
  • batch_size – Batch size.
  • repeat – Whether to repeat the iterator for multiple epochs.
  • shuffle – Whether to shuffle examples between epochs.
  • device (str or torch.device) – A string or instance of torch.device specifying which device the Variables are going to be created on. If None, the tensors will be created on cpu.
epoch
classmethod from_dataset(dataset: torch.utils.data.dataset.Dataset, batch_size: int, device: torch.device = None, repeat: bool = False, shuffle: Optional[bool] = None)
classmethod from_datasets(train_ds: torch.utils.data.dataset.Dataset, batch_size: Union[T, Iterable[T]], val_ds: Optional[torch.utils.data.dataset.Dataset] = None, test_ds: Optional[torch.utils.data.dataset.Dataset] = None, device: Union[T, Iterable[T]] = None, repeat: Union[T, Iterable[T]] = False, shuffle: Optional[Union[T, Iterable[T]]] = None) → Iterable[torchtable.loader.core.DefaultLoader]
init_epoch()

Set up the batch generator for a new epoch.

load_state_dict(state_dict: Dict[str, Any])
state_dict() → Dict[str, Any]