mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 18:56:36 +03:00
Support unseen classes in parser
This commit is contained in:
parent
4b5d1b53f6
commit
07a3581ff8
|
@ -267,6 +267,12 @@ class Parser(TrainablePipe):
|
|||
gZ = exp_gscores.sum(axis=1, keepdims=True)
|
||||
d_scores = exp_scores / Z
|
||||
d_scores[is_gold] -= exp_gscores / gZ
|
||||
if "unseen_classes" in model.attrs:
|
||||
for i in range(costs.shape[0]):
|
||||
for clas in range(costs.shape[1]):
|
||||
if costs[i, clas] <= best_costs[i, 0]:
|
||||
if clas in model.attrs["unseen_classes"]:
|
||||
model.attrs["unseen_classes"].remove(clas)
|
||||
return d_scores
|
||||
|
||||
def _get_costs_from_histories(self, examples, histories):
|
||||
|
|
Loading…
Reference in New Issue
Block a user