Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: bug fix in seq, kg dataloader && sampler #551

Merged
merged 5 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions recbole/data/dataloader/knowledge_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def _next_batch_data(self):
elif self.state == KGDataLoaderState.RS:
return self.general_dataloader._next_batch_data()
elif self.state == KGDataLoaderState.RSKG:
if self.kg_dataloader.pr >= self.kg_dataloader.pr_end:
self.kg_dataloader.pr = 0
kg_data = self.kg_dataloader._next_batch_data()
rec_data = self.general_dataloader._next_batch_data()
rec_data.update(kg_data)
Expand Down
2 changes: 1 addition & 1 deletion recbole/data/dataloader/neg_sample_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NegSampleMixin(AbstractDataLoader):
batch_size (int, optional): The batch_size of dataloader. Defaults to ``1``.
dl_format (InputType, optional): The input type of dataloader. Defaults to
:obj:`~recbole.utils.InputType.POINTWISE`.
shuffle (bool, optional): Whether the dataloader will be shuffle after a round. Defaluts to ``False``.
shuffle (bool, optional): Whether the dataloader will be shuffle after a round. Defaults to ``False``.
"""
dl_type = DataLoaderType.NEGSAMPLE

Expand Down
2 changes: 1 addition & 1 deletion recbole/data/dataloader/sequential_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def augmentation(self, uid_list, item_list_index, target_index, item_list_length
new_dict = {
self.uid_field: uid_list,
self.item_list_field: np.zeros((new_length, self.max_item_list_len), dtype=np.int64),
self.time_list_field: np.zeros((new_length, self.max_item_list_len), dtype=np.int64),
self.time_list_field: np.zeros((new_length, self.max_item_list_len)),
self.target_iid_field: self.dataset.inter_feat[self.iid_field][target_index].values,
self.target_time_field: self.dataset.inter_feat[self.time_field][target_index].values,
self.item_list_length_field: item_list_length,
Expand Down
2 changes: 1 addition & 1 deletion recbole/sampler/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def sample_by_key_ids(self, key_ids, num, used_ids):
key_num = len(key_ids)
total_num = key_num * num
value_ids = np.zeros(total_num, dtype=np.int64)
used_id_list = np.repeat(used_ids, num)
used_id_list = np.tile(used_ids, num)
for i, used_ids in enumerate(used_id_list):
cur = self.random()
while cur in used_ids:
Expand Down