question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: `training_neg_sample_num` should be 0 if inter_feat have label_field [label].

See original GitHub issue

I am getting the following error for LightGCN

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-0b2a29229228> in <module>
     47 
     48 # dataset splitting
---> 49 train_data, valid_data, test_data = data_preparation(config, dataset)
     50 
     51 # model loading and initialization

c:\users\laxmi\downloads\recbole\recbole\data\utils.py in data_preparation(config, dataset, save)
    101     if config['training_neg_sample_num']:
    102         if dataset.label_field in dataset.inter_feat:
--> 103             raise ValueError(f'`training_neg_sample_num` should be 0 '
    104                              f'if inter_feat have label_field [{dataset.label_field}].')
    105         train_distribution = config['training_neg_sample_distribution'] or 'uniform'

ValueError: `training_neg_sample_num` should be 0 if inter_feat have label_field [label].

If I set training_neg_sample_num=0 then I get another error saying

c:\users\laxmi\downloads\recbole\recbole\model\general_recommender\lightgcn.py in calculate_loss(self, interaction)
    136         user = interaction[self.USER_ID]
    137         pos_item = interaction[self.ITEM_ID]
--> 138         neg_item = interaction[self.NEG_ITEM_ID]
    139 
    140         user_all_embeddings, item_all_embeddings = self.forward()

c:\users\laxmi\downloads\recbole\recbole\data\interaction.py in __getitem__(self, index)
    103     def __getitem__(self, index):
    104         if isinstance(index, str):
--> 105             return self.interaction[index]
    106         else:
    107             ret = {}

KeyError: 'neg_pid'

Any idea, how to remove this error?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
2017pxycommented, Jan 15, 2021

@laxmimerit Yes! You are right, the process of converting token to id is called remap, which is done in dataset.py, and I must admit that it may bring some confusion to new comers.

1reaction
chenyushuocommented, Jan 14, 2021

Can you offer the full output of error? I’m confused, too. And you said that it will raise error when you pass some big number of uid, can you offer train_data.dataset.user_num and train_data.dataset.item_num?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found