bugfix: update states after creating golds to avoid out of bounds indexing

This commit is contained in:
svlandeg 2020-06-23 14:49:31 +02:00
parent 790b373901
commit 5cf3eeee0d

View File

@ -615,8 +615,8 @@ cdef class ArcEager(TransitionSystem):
def init_gold_batch(self, examples): def init_gold_batch(self, examples):
states = self.init_batch([eg.predicted for eg in examples]) states = self.init_batch([eg.predicted for eg in examples])
keeps = [i for i, s in enumerate(states) if not s.is_final()] keeps = [i for i, s in enumerate(states) if not s.is_final()]
states = [states[i] for i in keeps]
golds = [ArcEagerGold(self, states[i], examples[i]) for i in keeps] golds = [ArcEagerGold(self, states[i], examples[i]) for i in keeps]
states = [states[i] for i in keeps]
for gold in golds: for gold in golds:
self._replace_unseen_labels(gold) self._replace_unseen_labels(gold)
n_steps = sum([len(s.queue) * 4 for s in states]) n_steps = sum([len(s.queue) * 4 for s in states])