在SpaCy NER训练中设置验证数据。

huangapple go评论108阅读模式
英文:

Set validation data in SpaCy NER training

问题

SpaCy NER 是否可以使用验证数据进行训练?或者像在 Keras 中一样将一些数据拆分为验证集(类似于 model.fit 中的 validation_split)?谢谢

with nlp.disable_pipes(*other_pipes):  # 仅训练 NER
        for itn in tqdm(range(n_iter)):
            random.shuffle(train_data_list)
            losses = {}
            # 使用spaCy的小批量方法来批量处理示例
            batches = minibatch(train_data_list, size=compounding(8., 64., 1.001))
            for batch in batches:
                texts, annotations = zip(*batch)
                nlp.update(texts, annotations, sgd=optimizer, drop=0.35,
                           losses=losses)
英文:

Is it possible to train SpaCy NER with validation data?
Or split some data to validation set like in Keras (validation_split in model.fit)? Thanks

with nlp.disable_pipes(*other_pipes):  # only train NER
        for itn in tqdm(range(n_iter)):
            random.shuffle(train_data_list)
            losses = {}
            # batch up the examples using spaCy's minibatch
            batches = minibatch(train_data_list, size=compounding(8., 64., 1.001))
            for batch in batches:
                texts, annotations = zip(*batch)
                nlp.update(texts, annotations, sgd=optimizer, drop=0.35,
                           losses=losses)

答案1

得分: 2

使用spacy train CLI代替演示脚本:

spacy train lang /path/to/output train.json dev.json

验证数据用于从训练迭代中选择最佳模型,也可用于提前停止。

主要任务是将您的数据转换为spaCy的JSON训练格式,请参阅:https://stackoverflow.com/a/59209377/461847

英文:

Use the spacy train CLI instead of the demo script:

spacy train lang /path/to/output train.json dev.json

The validation data is used to choose the best model from the training iterations and optionally for early stopping.

The main task is converting your data to spacy's JSON training format, see: https://stackoverflow.com/a/59209377/461847

huangapple
  • 本文由 发表于 2020年1月6日 16:45:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/59609034.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定