mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
[ci skip] Add breakpoint for debugging
This commit is contained in:
parent
5452e71b05
commit
d6e56b62b9
|
@ -79,9 +79,9 @@ def make_spancat(
|
||||||
spans_key: str,
|
spans_key: str,
|
||||||
scorer: Optional[Callable],
|
scorer: Optional[Callable],
|
||||||
negative_weight: float = 1.0,
|
negative_weight: float = 1.0,
|
||||||
allow_overlap: Optional[bool] = True,
|
allow_overlap: bool = True,
|
||||||
) -> "SpanCategorizerExclusive":
|
) -> "SpanCategorizerExclusive":
|
||||||
"""Create a SpanCategorizer component. The span categorizer consists of two
|
"""Create a SpanCategorizerExclusive component. The span categorizer consists of two
|
||||||
parts: a suggester function that proposes candidate spans, and a labeller
|
parts: a suggester function that proposes candidate spans, and a labeller
|
||||||
model that predicts one or more labels for each span.
|
model that predicts one or more labels for each span.
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ def make_spancat(
|
||||||
reference document under the same key.
|
reference document under the same key.
|
||||||
negative_weight (float): Multiplier for the loss terms.
|
negative_weight (float): Multiplier for the loss terms.
|
||||||
Can be used to down weigh the negative samples if there are too many.
|
Can be used to down weigh the negative samples if there are too many.
|
||||||
allow_overlap (Optional[bool]): If True the data is assumed to
|
allow_overlap (bool): If True the data is assumed to
|
||||||
contain overlapping spans.
|
contain overlapping spans.
|
||||||
"""
|
"""
|
||||||
return SpanCategorizerExclusive(
|
return SpanCategorizerExclusive(
|
||||||
|
@ -148,8 +148,8 @@ class SpanCategorizerExclusive(TrainablePipe):
|
||||||
*,
|
*,
|
||||||
spans_key: str = "spans",
|
spans_key: str = "spans",
|
||||||
negative_weight: float = 1.0,
|
negative_weight: float = 1.0,
|
||||||
|
allow_overlap: bool = True,
|
||||||
scorer: Optional[Callable] = spancat_score,
|
scorer: Optional[Callable] = spancat_score,
|
||||||
allow_overlap: Optional[bool] = True,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the span categorizer.
|
"""Initialize the span categorizer.
|
||||||
vocab (Vocab): The shared vocabulary.
|
vocab (Vocab): The shared vocabulary.
|
||||||
|
@ -162,11 +162,11 @@ class SpanCategorizerExclusive(TrainablePipe):
|
||||||
`"spans"`.
|
`"spans"`.
|
||||||
negative_weight (float): Multiplier for the loss terms.
|
negative_weight (float): Multiplier for the loss terms.
|
||||||
Can be used to down weigh the negative samples if there are too many.
|
Can be used to down weigh the negative samples if there are too many.
|
||||||
|
allow_overlap (bool): If True the data is assumed to
|
||||||
|
contain overlapping spans.
|
||||||
scorer (Optional[Callable]): The scoring method. Defaults to
|
scorer (Optional[Callable]): The scoring method. Defaults to
|
||||||
Scorer.score_spans for the Doc.spans[spans_key] with overlapping
|
Scorer.score_spans for the Doc.spans[spans_key] with overlapping
|
||||||
spans allowed.
|
spans allowed.
|
||||||
allow_overlap (Optional[bool]): If True the data is assumed to
|
|
||||||
contain overlapping spans.
|
|
||||||
|
|
||||||
DOCS: https://spacy.io/api/spancategorizerexclusive#init
|
DOCS: https://spacy.io/api/spancategorizerexclusive#init
|
||||||
"""
|
"""
|
||||||
|
@ -376,6 +376,7 @@ class SpanCategorizerExclusive(TrainablePipe):
|
||||||
offset += spans.lengths[i]
|
offset += spans.lengths[i]
|
||||||
target = self.model.ops.asarray(target, dtype="f") # type: ignore
|
target = self.model.ops.asarray(target, dtype="f") # type: ignore
|
||||||
negative_samples = numpy.nonzero(negative_spans)[0]
|
negative_samples = numpy.nonzero(negative_spans)[0]
|
||||||
|
breakpoint()
|
||||||
target[negative_samples, self._negative_label] = 1.0
|
target[negative_samples, self._negative_label] = 1.0
|
||||||
d_scores = scores - target
|
d_scores = scores - target
|
||||||
neg_weight = self.cfg["negative_weight"]
|
neg_weight = self.cfg["negative_weight"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user