如何解决spacy textcat 的损失计算告诉我什么?
我是 NLP 和 spacy 的新手。 spacy textcat 中的“损失”是什么意思?在使用 spacy textcat 模型训练构建自定义文本分类器期间,所有迭代的值都为 0.0000。我想知道我的模型训练是否有问题。
for i in range(n_iter):
losses = {}
# batch up the examples using spaCy's minibatch
batches = minibatch(train_data,size=compounding(4.,32.,1.001))
for batch in batches:
texts,annotations = zip(*batch)
#print('texts: '+str(texts))
#print('annotations: '+str(annotations))
nlp.update(texts,annotations,sgd=optimizer,drop=0.2,losses=losses)
# with textcat.model.use_params(optimizer.averages):
# evaluate on the dev data split off in load_data()
print('{0:.3f}' # print a simple table
.format(losses['textcat']))
output_dir 下面的代码是什么意思?
if output_dir is not None:
output_dir = Path(output_dir)
if not output_dir.exists():
output_dir.mkdir()
nlp.to_disk(output_dir)
print("Saved model to",output_dir)
# test the saved model
print("Loading from",output_dir)
nlp2 = spacy.load(output_dir)
doc2 = nlp2(test_text)
print(test_text,doc2.cats)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。