mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Use hash_state in beam
This commit is contained in:
parent
693c8934e8
commit
b13b2aeb54
|
@ -96,7 +96,7 @@ cdef class ParserBeam(object):
|
||||||
self._set_scores(beam, scores[i])
|
self._set_scores(beam, scores[i])
|
||||||
if self.golds is not None:
|
if self.golds is not None:
|
||||||
self._set_costs(beam, self.golds[i], follow_gold=follow_gold)
|
self._set_costs(beam, self.golds[i], follow_gold=follow_gold)
|
||||||
beam.advance(transition_state, NULL, <void*>self.moves.c)
|
beam.advance(transition_state, hash_state, <void*>self.moves.c)
|
||||||
beam.check_done(check_final_state, NULL)
|
beam.check_done(check_final_state, NULL)
|
||||||
# This handles the non-monotonic stuff for the parser.
|
# This handles the non-monotonic stuff for the parser.
|
||||||
if beam.is_done and self.golds is not None:
|
if beam.is_done and self.golds is not None:
|
||||||
|
|
|
@ -119,6 +119,8 @@ cdef class Parser:
|
||||||
cfg['beam_width'] = util.env_opt('beam_width', 1)
|
cfg['beam_width'] = util.env_opt('beam_width', 1)
|
||||||
if 'beam_density' not in cfg:
|
if 'beam_density' not in cfg:
|
||||||
cfg['beam_density'] = util.env_opt('beam_density', 0.0)
|
cfg['beam_density'] = util.env_opt('beam_density', 0.0)
|
||||||
|
if 'beam_update_prob' not in cfg:
|
||||||
|
cfg['beam_update_prob'] = util.env_opt('beam_update_prob', 1.0)
|
||||||
cfg.setdefault('cnn_maxout_pieces', 3)
|
cfg.setdefault('cnn_maxout_pieces', 3)
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
self.model = model
|
self.model = model
|
||||||
|
@ -383,7 +385,7 @@ cdef class Parser:
|
||||||
self.moves.set_valid(beam.is_valid[i], state)
|
self.moves.set_valid(beam.is_valid[i], state)
|
||||||
memcpy(beam.scores[i], c_scores, scores.shape[1] * sizeof(float))
|
memcpy(beam.scores[i], c_scores, scores.shape[1] * sizeof(float))
|
||||||
c_scores += scores.shape[1]
|
c_scores += scores.shape[1]
|
||||||
beam.advance(_beam_utils.transition_state, NULL, <void*>self.moves.c)
|
beam.advance(_beam_utils.transition_state, _beam_utils.hash_state, <void*>self.moves.c)
|
||||||
beam.check_done(_beam_utils.check_final_state, NULL)
|
beam.check_done(_beam_utils.check_final_state, NULL)
|
||||||
return [b for b in beams if not b.is_done]
|
return [b for b in beams if not b.is_done]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user