Skip to content

handlertorch

This file provides the class API for handling the data in pytorch using the Dataset and Dataloader classes.

Classes:

TorchDataset

TorchDataset(
    config_path: str,
    csv_path: str,
    encoder_loader: EncoderLoader,
    split: Optional[int] = None,
)

Bases: Dataset

Class for creating a torch dataset.

Parameters:

  • config_path (str) –

    Path to the configuration file

  • csv_path (str) –

    Path to the CSV data file

  • encoder_loader (EncoderLoader) –

    Encoder loader instance

  • split (Optional[int], default: None ) –

    Optional tuple containing split information

Source code in src/stimulus/data/handlertorch.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(
    self,
    config_path: str,
    csv_path: str,
    encoder_loader: loaders.EncoderLoader,
    split: Optional[int] = None,
) -> None:
    """Initialize the TorchDataset.

    Args:
        config_path: Path to the configuration file
        csv_path: Path to the CSV data file
        encoder_loader: Encoder loader instance
        split: Optional tuple containing split information
    """
    self.loader = data_handlers.DatasetLoader(
        config_path=config_path,
        csv_path=csv_path,
        encoder_loader=encoder_loader,
        split=split,
    )