From cb2364cf834b7bcf713fbda055dd97d114deac9f Mon Sep 17 00:00:00 2001 From: Paul O'Leary McCann Date: Thu, 17 Jun 2021 17:56:00 +0900 Subject: [PATCH] Fix type of mask The call here was creating a float64 array, which was turning many downstream scores into float64s. Later on these values were assigned to a float32 array in backprop, and numerical underflow caused things to go to zero. That's almost certainly not the only reason things go to zero, but it is incorrect. --- spacy/ml/models/coref.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/ml/models/coref.py b/spacy/ml/models/coref.py index 723984768..fd36c84f7 100644 --- a/spacy/ml/models/coref.py +++ b/spacy/ml/models/coref.py @@ -373,7 +373,7 @@ def ant_scorer_forward( warnings.filterwarnings('ignore', category=RuntimeWarning) mask = xp.log( (xp.expand_dims(ant_range, 1) - xp.expand_dims(ant_range, 0)) >= 1 - ).astype(float) + ).astype('f') scores = pw_prod + pw_sum + mask