Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small update_with_oracle_cut_size fixes #12314

Draft
wants to merge 3 commits into
base: v5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spacy/ml/tb_framework.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ def _forward_fallback(
all_ids.append(ids)
all_statevecs.append(statevecs)
all_which.append(which)
n_moves += 1
if n_moves >= max_moves >= 1:
break
n_moves += 1

def backprop_parser(d_states_d_scores):
ids = ops.xp.vstack(all_ids)
Expand Down
9 changes: 4 additions & 5 deletions spacy/pipeline/transition_parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class Parser(TrainablePipe):
# batch uniform length. Since we do not have a gold standard
# sequence, we use the teacher's predictions as the gold
# standard.
max_moves = int(random.uniform(max(max_moves // 2, 1), max_moves * 2))
max_moves = random.randrange(max(max_moves // 2, 1), max_moves * 2)
states = self._init_batch_from_teacher(teacher_pipe, student_docs, max_moves)
else:
states = self.moves.init_batch(student_docs)
Expand Down Expand Up @@ -425,7 +425,7 @@ class Parser(TrainablePipe):
if max_moves >= 1:
# Chop sequences into lengths of this many words, to make the
# batch uniform length.
max_moves = int(random.uniform(max(max_moves // 2, 1), max_moves * 2))
max_moves = random.randrange(max(max_moves // 2, 1), max_moves * 2)
init_states, gold_states, _ = self._init_gold_batch(
examples,
max_length=max_moves
Expand Down Expand Up @@ -729,9 +729,8 @@ class Parser(TrainablePipe):
action.do(state.c, action.label)
if state.is_final():
break
if moves.has_gold(eg, start_state.B(0), state.B(0)):
states.append(start_state)
golds.append(gold)
states.append(start_state)
golds.append(gold)
danieldk marked this conversation as resolved.
Show resolved Hide resolved
if state.is_final():
break
return states, golds, max_length
Expand Down