recbole.data.dataloader.abstract_dataloader

class recbole.data.dataloader.abstract_dataloader.AbstractDataLoader(config, dataset, batch_size=1, dl_format=<InputType.POINTWISE: 1>, shuffle=False)[source]

Bases: object

AbstractDataLoader is an abstract object which would return a batch of data which is loaded by Interaction when it is iterated. And it is also the ancestor of all other dataloader.

Parameters
  • config (Config) – The config of dataloader.

  • dataset (Dataset) – The dataset of dataloader.

  • batch_size (int, optional) – The batch_size of dataloader. Defaults to 1.

  • dl_format (InputType, optional) – The input type of dataloader. Defaults to POINTWISE.

  • shuffle (bool, optional) – Whether the dataloader will be shuffle after a round. Defaults to False.

dataset

The dataset of this dataloader.

Type

Dataset

shuffle

If True, dataloader will shuffle before every epoch.

Type

bool

real_time

If True, dataloader will do data pre-processing, such as neg-sampling and data-augmentation.

Type

bool

pr

Pointer of dataloader.

Type

int

step

The increment of pr for each batch.

Type

int

batch_size

The max interaction number for all batch.

Type

int

data_preprocess()[source]

This function is used to do some data preprocess, such as pre-data-augmentation. By default, it will do nothing.

dl_type = None
property pr_end

This property marks the end of dataloader.pr which is used in __next__().

set_batch_size(batch_size)[source]

Reset the batch_size of the dataloader, but it can’t be called when dataloader is being iterated.

Parameters

batch_size (int) – the new batch_size of dataloader.

setup()[source]

This function can be used to deal with some problems after essential args are initialized, such as the batch-size-adaptation when neg-sampling is needed, and so on. By default, it will do nothing.

upgrade_batch_size(batch_size)[source]

Upgrade the batch_size of the dataloader, if input batch_size is bigger than current batch_size.

Parameters

batch_size (int) – the new batch_size of dataloader.