LRDataset

class jlpy.pytorch.base.linear_regression.base_impl.LRDataset

Bases: Dataset[tuple[Tensor, Tensor]]

Training dataset or validation dataset for the linear regression.

Methods

__init__

Construct a class instance.

custom_collate

Collate batch input to output without any changes.

__init__(data: LRData, *, isval: bool = False) None

Construct a class instance.

__getitem__(idx: int) tuple[Tensor, Tensor]

Subscription method for the dataset.

Parameters:

idx (int) – Index of the subscription.

Retrn:

Return one element from the dataset.

Return type:

tuple[Tensor, Tensor]

static custom_collate(batch: tuple[Tensor, Tensor]) tuple[Tensor, Tensor]

Collate batch input to output without any changes.

  • Default collate:
    • Merge a list of one element from the dataset to a Tensor collection format.

  • Custom collate:
    • If there is a way to load batched samplers from database, bypass the default collate method.

Parameters:

batch (tuple[Tensor, Tensor]) – Batch input returned from __getitems__().

Returns:

Return the original input.

Return type:

tuple[Tensor, Tensor]