Skip to content

Commit bd63bf3

Browse files
Fixed PopularityBasedSamplerV2 that was raising error when the sampled item is equal the item id cardinality
1 parent bc7ac95 commit bd63bf3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

merlin/models/tf/outputs/sampling/popularity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_sampling_distribution(self) -> tf.Tensor:
147147
tf.Tensor
148148
Probabilities of each item to be sampled
149149
"""
150-
log_indices = tf.math.log(tf.range(1.0, self.max_id - self.min_id + 2.0, 1.0))
150+
log_indices = tf.math.log(tf.range(1.0, self.max_id - self.min_id + 3.0, 1.0))
151151
sampling_probs = (log_indices[1:] - log_indices[:-1]) / log_indices[-1]
152152

153153
if self.unique:

0 commit comments

Comments
 (0)