hopwise.data.dataloader.knowledge_dataloader¶
Classes¶
|
|
|
|
|
Module Contents¶
- class hopwise.data.dataloader.knowledge_dataloader.KGDataLoader(config, dataset, sampler, shuffle=False)¶
Bases:
hopwise.data.dataloader.abstract_dataloader.AbstractDataLoaderKGDataLoaderis a dataloader which would return the triplets with negative examples in a knowledge graph.- Parameters:
- shuffle¶
Whether the dataloader will be shuffle after a round. However, in
KGDataLoader, it’s guaranteed to beTrue.- Type:
bool
- logger¶
- neg_sample_num = 1¶
- neg_prefix¶
- hid_field¶
- tid_field¶
- neg_tid_field¶
- sample_size¶
- _init_batch_size_and_step()¶
Initializing
stepandbatch_size.
- collate_fn(index)¶
Collect the sampled index, and apply neg_sampling or other methods to get the final data.
- class hopwise.data.dataloader.knowledge_dataloader.KnowledgeBasedDataLoader(config, dataset, sampler, kg_sampler, shuffle=False)¶
KnowledgeBasedDataLoaderis 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 user-item interaction. In the second state, this dataloader would only return the triplets with negative examples in a knowledge graph. In the last state, this dataloader would return both knowledge graph information and user-item interaction information.
- Type:
- logger¶
- general_dataloader¶
- kg_dataloader¶
- shuffle = False¶
- state = None¶
- update_config(config)¶
- __iter__()¶
- __next__()¶
- __len__()¶
- set_mode(state)¶
- 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
- get_model(model)¶
Let the general_dataloader get the model, used for dynamic sampling.
- knowledge_shuffle(epoch_seed)¶
Reset the seed to ensure that each subprocess generates the same index squence.
- class hopwise.data.dataloader.knowledge_dataloader.KnowledgePathEvalDataLoader(config, dataset, sampler, shuffle=False)¶
Bases:
hopwise.data.dataloader.general_dataloader.FullSortRecEvalDataLoaderFullSortRecEvalDataLoaderis a dataloader for full-sort evaluation for the recommendation (Rec) task.- Parameters:
- inference_tokenized_dataset¶
- _init_batch_size_and_step()¶
Initializing
stepandbatch_size.
- collate_fn(index)¶
Collect the sampled index, and apply neg_sampling or other methods to get the final data.