mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
Fix issue #3112 part 1
This commit is contained in:
parent
b21481eeca
commit
6574e4f2d3
|
@ -261,8 +261,9 @@ class ParserStepModel(Model):
|
||||||
# lowest score.
|
# lowest score.
|
||||||
# numpy's nan_to_num function doesn't take a value, and nan is replaced
|
# numpy's nan_to_num function doesn't take a value, and nan is replaced
|
||||||
# by 0...-inf is replaced by minimum, so we go via that. Ugly to the max.
|
# by 0...-inf is replaced by minimum, so we go via that. Ugly to the max.
|
||||||
scores[self.ops.xp.isnan(scores)] = -self.ops.xp.inf
|
# Note that scores is always a numpy array! Should fix #3112
|
||||||
self.ops.xp.nan_to_num(scores, copy=False)
|
scores[numpy.isnan(scores)] = -numpy.inf
|
||||||
|
numpy.nan_to_num(scores, copy=False)
|
||||||
|
|
||||||
def backprop_parser_step(d_scores, sgd=None):
|
def backprop_parser_step(d_scores, sgd=None):
|
||||||
# If we have a non-zero gradient for a previously unseen class,
|
# If we have a non-zero gradient for a previously unseen class,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user