Fix flake8

This commit is contained in:
Matthew Honnibal 2020-06-23 13:26:38 +02:00
parent 1682a60a20
commit 6f7f2131cb
2 changed files with 3 additions and 4 deletions

View File

@ -80,13 +80,12 @@ def _get_transition_table(
B_start, B_end = (0, n_labels)
I_start, I_end = (B_end, B_end + n_labels)
L_start, L_end = (I_end, I_end + n_labels)
U_start, U_end = (L_end, L_end + n_labels)
U_start, _ = (L_end, L_end + n_labels)
# Using ranges allows us to set specific cells, which is necessary to express
# that only actions of the same label are valid continuations.
B_range = numpy.arange(B_start, B_end)
I_range = numpy.arange(I_start, I_end)
L_range = numpy.arange(L_start, L_end)
O_action = U_end
# If this is the last token and the previous action was B or I, only L
# of that label is valid
table[1, B_range, L_range] = 1

View File

@ -38,8 +38,8 @@ def forward(model, X, is_train):
def init(model, X=None, Y=None):
tok2vec = model.get_ref("tok2vec").initialize(X=X)
lower = model.get_ref("lower").initialize()
model.get_ref("tok2vec").initialize(X=X)
model.get_ref("lower").initialize()
if model.attrs["has_upper"]:
statevecs = model.ops.alloc2f(2, lower.get_dim("nO"))
model.get_ref("upper").initialize(X=statevecs)