mirror of https://github.com/explosion/spaCy.git
Merge from develop
This commit is contained in:
parent
7f5715a081
commit
24efd54a42
|
@ -224,8 +224,9 @@ def train_from_config(
|
|||
|
||||
|
||||
def create_train_batches(nlp, corpus, cfg):
|
||||
is_first = True
|
||||
while True:
|
||||
train_examples = list(corpus.train_dataset(
|
||||
train_examples = corpus.train_dataset(
|
||||
nlp,
|
||||
noise_level=0.0,
|
||||
orth_variant_level=cfg["orth_variant_level"],
|
||||
|
@ -323,6 +324,8 @@ def train_while_improving(
|
|||
for subbatch in subdivide_batch(batch, accumulate_gradient):
|
||||
nlp.update(subbatch, drop=dropout, losses=losses, sgd=False)
|
||||
for name, proc in nlp.pipeline:
|
||||
for name, proc in nlp.pipeline:
|
||||
if hasattr(proc, "model"):
|
||||
proc.model.finish_update(optimizer)
|
||||
optimizer.step_schedules()
|
||||
if not (step % eval_frequency):
|
||||
|
|
|
@ -474,7 +474,11 @@ cdef class precompute_hiddens:
|
|||
# This will usually be on GPU
|
||||
d_best = ops.asarray(d_best)
|
||||
# Fix nans (which can occur from unseen classes.)
|
||||
try:
|
||||
d_best[ops.xp.isnan(d_best)] = 0.
|
||||
except:
|
||||
print(ops.xp.isnan(d_best))
|
||||
raise
|
||||
if self.activation == "maxout":
|
||||
mask_ = ops.asarray(mask)
|
||||
return ops.backprop_maxout(d_best, mask_, self.nP)
|
||||
|
|
|
@ -598,13 +598,6 @@ def minibatch_by_words(examples, size, tuples=True, count_words=len, tolerance=0
|
|||
try:
|
||||
example = next(examples)
|
||||
except StopIteration:
|
||||
if oversize:
|
||||
examples = iter(oversize)
|
||||
oversize = []
|
||||
if batch:
|
||||
yield batch
|
||||
break
|
||||
else:
|
||||
if batch:
|
||||
yield batch
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue