recbole.data.dataloader.knowledge_dataloader¶
- class recbole.data.dataloader.knowledge_dataloader.KGDataLoader(config, dataset, sampler, shuffle=False)[source]¶
Bases:
AbstractDataLoaderKGDataLoaderis a dataloader which would return the triplets with negative examples in a knowledge graph.- Parameters:
config (Config) – The config of dataloader.
dataset (Dataset) – The dataset of dataloader.
sampler (KGSampler) – The knowledge graph sampler of dataloader.
shuffle (bool, optional) – Whether the dataloader will be shuffle after a round. Defaults to
False.
- shuffle¶
Whether the dataloader will be shuffle after a round. However, in
KGDataLoader, it’s guaranteed to beTrue.- Type:
bool
- class recbole.data.dataloader.knowledge_dataloader.KnowledgeBasedDataLoader(config, dataset, sampler, kg_sampler, shuffle=False)[source]¶
Bases:
objectKnowledgeBasedDataLoaderis used for knowledge based model. It has three states, which is saved instate. In different states,_next_batch_data()will return differentInteraction. Detailed, please seestate.- Parameters:
config (Config) – The config of dataloader.
dataset (Dataset) – The dataset of dataloader.
sampler (Sampler) – The sampler of dataloader.
kg_sampler (KGSampler) – The knowledge graph sampler of dataloader.
shuffle (bool, optional) – Whether the dataloader will be shuffle after a round. Defaults to
False.
- state¶
-
In the first state, this dataloader would only return the triplets with negative examples in a knowledge graph. In the second state, this dataloader would only return the user-item interaction. In the last state, this dataloader would return both knowledge graph information and user-item interaction information.
- Type:
- knowledge_shuffle(epoch_seed)[source]¶
Reset the seed to ensure that each subprocess generates the same index squence.
- set_mode(state)[source]¶
- Set the mode of
KnowledgeBasedDataLoader, it can be set to three states: KGDataLoaderState.RS
KGDataLoaderState.KG
KGDataLoaderState.RSKG
The state of
KnowledgeBasedDataLoaderwould affect the result of _next_batch_data().- Parameters:
state (KGDataLoaderState) – the state of
KnowledgeBasedDataLoader.
- Set the mode of