mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 02:06:31 +03:00
Fix begin_training
This commit is contained in:
parent
d507ac28d8
commit
bc94fdabd0
|
@ -532,10 +532,14 @@ class Tagger(Pipe):
|
|||
exc=vocab.morphology.exc)
|
||||
self.set_output(len(self.labels))
|
||||
doc_sample = [Doc(self.vocab, words=["hello", "world"])]
|
||||
for name, component in pipeline:
|
||||
if component is self:
|
||||
break
|
||||
doc_sample = list(component.pipe(doc_sample))
|
||||
if pipeline is not None:
|
||||
for name, component in pipeline:
|
||||
if component is self:
|
||||
break
|
||||
if hasattr(component, "pipe"):
|
||||
doc_sample = list(component.pipe(doc_sample))
|
||||
else:
|
||||
doc_sample = [component(doc) for doc in doc_sample]
|
||||
self.model.initialize(X=doc_sample)
|
||||
# Get batch of example docs, example outputs to call begin_training().
|
||||
# This lets the model infer shapes.
|
||||
|
|
|
@ -630,11 +630,19 @@ cdef class Parser:
|
|||
if len(doc):
|
||||
doc_sample.append(doc)
|
||||
gold_sample.append(gold)
|
||||
for name, component in pipeline:
|
||||
if component is self:
|
||||
break
|
||||
doc_sample = list(component.pipe(doc_sample))
|
||||
self.model.initialize(doc_sample, gold_sample)
|
||||
|
||||
if pipeline is not None:
|
||||
for name, component in pipeline:
|
||||
if component is self:
|
||||
break
|
||||
if hasattr(component, "pipe"):
|
||||
doc_sample = list(component.pipe(doc_sample))
|
||||
else:
|
||||
doc_sample = [component(doc) for doc in doc_sample]
|
||||
if doc_sample:
|
||||
self.model.initialize(doc_sample)
|
||||
else:
|
||||
self.model.initialize()
|
||||
if pipeline is not None:
|
||||
self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
|
||||
link_vectors_to_models(self.vocab)
|
||||
|
|
Loading…
Reference in New Issue
Block a user