diff --git a/recommenders/models/deeprec/DataModel/ImplicitCF.py b/recommenders/models/deeprec/DataModel/ImplicitCF.py index 3cfbb2821..42bb319c4 100644 --- a/recommenders/models/deeprec/DataModel/ImplicitCF.py +++ b/recommenders/models/deeprec/DataModel/ImplicitCF.py @@ -206,6 +206,8 @@ def train_loader(self, batch_size): """ def sample_neg(x): + if len(x) >= self.n_items: + raise ValueError("A user has voted in every item. Can't find a negative sample.") while True: neg_id = random.randint(0, self.n_items - 1) if neg_id not in x: