mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-02 19:30:19 +03:00
Improve the correctness of _parse_patch
* If there are no more actions, do not attempt to make further transitions, even if not all states are final. * Assert that the number of actions for a step is the same as the number of states.
This commit is contained in:
parent
c6cca4c00a
commit
6cabbd2fb5
|
@ -249,9 +249,11 @@ cdef list _parse_batch(CBlas cblas, TransitionSystem moves, StateC** states,
|
||||||
cdef np.ndarray step_actions
|
cdef np.ndarray step_actions
|
||||||
|
|
||||||
scores = []
|
scores = []
|
||||||
while sizes.states >= 1:
|
while sizes.states >= 1 and (actions is None or actions):
|
||||||
step_scores = numpy.empty((sizes.states, sizes.classes), dtype="f")
|
step_scores = numpy.empty((sizes.states, sizes.classes), dtype="f")
|
||||||
step_actions = actions[0] if actions is not None else None
|
step_actions = actions[0] if actions is not None else None
|
||||||
|
assert step_actions is None or step_actions.size == sizes.states, \
|
||||||
|
f"number of step actions ({step_actions.size}) must equal number of states ({sizes.states})"
|
||||||
with nogil:
|
with nogil:
|
||||||
_predict_states(cblas, &activations, <float*>step_scores.data, states, &weights, sizes)
|
_predict_states(cblas, &activations, <float*>step_scores.data, states, &weights, sizes)
|
||||||
if actions is None:
|
if actions is None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user