Skip to content

Commit

Permalink
Merge pull request #779 from jibrilfrej/2.2-dev
Browse files Browse the repository at this point in the history
Update rank_cross_entropy_loss to avoid NANs
  • Loading branch information
jibrilfrej committed Aug 7, 2019
2 parents 61f4ae6 + 4a39fbe commit 1bb467c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion matchzoo/losses/rank_cross_entropy_loss.py
Expand Up @@ -48,7 +48,7 @@ def __call__(self, y_true: np.array, y_pred: np.array) -> np.array:
labels.append(neg_labels)
logits = K.concatenate(logits, axis=-1)
labels = K.concatenate(labels, axis=-1)
return -K.mean(K.sum(labels * K.log(K.softmax(logits)), axis=-1))
return -K.mean(K.sum(labels * K.log(K.softmax(logits) + np.finfo(float).eps), axis=-1))

@property
def num_neg(self):
Expand Down

0 comments on commit 1bb467c

Please sign in to comment.