mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Remove Beam cleanup (#6414)
Beam cleanup is handled through the Beam finalization method.
This commit is contained in:
parent
a8c2dad466
commit
4284605683
|
@ -304,27 +304,3 @@ def get_gradient(nr_class, beam_maps, histories, losses):
|
|||
grads[j][i, clas] += loss
|
||||
key = key + tuple([clas])
|
||||
return grads
|
||||
|
||||
|
||||
def cleanup_beam(Beam beam):
|
||||
cdef StateC* state
|
||||
# Once parsing has finished, states in beam may not be unique. Is this
|
||||
# correct?
|
||||
seen = set()
|
||||
for i in range(beam.width):
|
||||
addr = <size_t>beam._parents[i].content
|
||||
if addr not in seen:
|
||||
state = <StateC*>addr
|
||||
del state
|
||||
seen.add(addr)
|
||||
else:
|
||||
raise ValueError(Errors.E023.format(addr=addr, i=i))
|
||||
addr = <size_t>beam._states[i].content
|
||||
if addr not in seen:
|
||||
state = <StateC*>addr
|
||||
del state
|
||||
seen.add(addr)
|
||||
else:
|
||||
raise ValueError(Errors.E023.format(addr=addr, i=i))
|
||||
|
||||
|
||||
|
|
|
@ -373,8 +373,6 @@ cdef class Parser:
|
|||
self.moves.finalize_doc(doc)
|
||||
for hook in self.postprocesses:
|
||||
hook(doc)
|
||||
for beam in beams:
|
||||
_beam_utils.cleanup_beam(beam)
|
||||
|
||||
def transition_states(self, states, float[:, ::1] scores):
|
||||
cdef StateClass state
|
||||
|
@ -527,9 +525,6 @@ cdef class Parser:
|
|||
else:
|
||||
model.backprops.append((ids, d_vector, bp_vectors))
|
||||
model.make_updates(sgd)
|
||||
cdef Beam beam
|
||||
for beam in beams:
|
||||
_beam_utils.cleanup_beam(beam)
|
||||
|
||||
def _init_gold_batch(self, whole_docs, whole_golds, min_length=5, max_length=500):
|
||||
"""Make a square batch, of length equal to the shortest doc. A long
|
||||
|
|
Loading…
Reference in New Issue
Block a user