mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Fix GPU evaluation
This commit is contained in:
parent
c2c825127a
commit
bbb59e371c
|
@ -71,7 +71,8 @@ class Trainer(object):
|
||||||
self.nr_epoch += 1
|
self.nr_epoch += 1
|
||||||
|
|
||||||
def evaluate(self, dev_sents, gold_preproc=False):
|
def evaluate(self, dev_sents, gold_preproc=False):
|
||||||
scorer = Scorer()
|
all_docs = []
|
||||||
|
all_golds = []
|
||||||
for raw_text, paragraph_tuples in dev_sents:
|
for raw_text, paragraph_tuples in dev_sents:
|
||||||
if gold_preproc:
|
if gold_preproc:
|
||||||
raw_text = None
|
raw_text = None
|
||||||
|
@ -79,12 +80,11 @@ class Trainer(object):
|
||||||
paragraph_tuples = merge_sents(paragraph_tuples)
|
paragraph_tuples = merge_sents(paragraph_tuples)
|
||||||
docs = self.make_docs(raw_text, paragraph_tuples)
|
docs = self.make_docs(raw_text, paragraph_tuples)
|
||||||
golds = self.make_golds(docs, paragraph_tuples)
|
golds = self.make_golds(docs, paragraph_tuples)
|
||||||
for doc, gold in zip(docs, golds):
|
all_docs.extend(docs)
|
||||||
state = {}
|
all_golds.extend(golds)
|
||||||
for process in self.nlp.pipeline:
|
scorer = Scorer()
|
||||||
assert state is not None, process.name
|
for doc, gold in zip(self.nlp.pipe(all_docs), all_golds):
|
||||||
state = process(doc, state=state)
|
scorer.score(doc, gold)
|
||||||
scorer.score(doc, gold)
|
|
||||||
return scorer
|
return scorer
|
||||||
|
|
||||||
def make_docs(self, raw_text, paragraph_tuples):
|
def make_docs(self, raw_text, paragraph_tuples):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user