683d81bb49096867f5ad8d3dde23217ea54d6790,examples/training/train_new_entity_type.py,,train_ner,#Any#Any#Any#,41

Before Change


def train_ner(nlp, train_data, output_dir):
    // Add new words to vocab
    for raw_text, _ in train_data:
        doc = nlp.make_doc(raw_text)
        for word in doc:
            _ = nlp.vocab[word.orth]
    random.seed(0)
    // You may need to change the learning rate. It"s generally difficult to
    // guess what rate you should set, especially when you have limited data.
    nlp.entity.model.learn_rate = 0.001
    for itn in range(1000):
        random.shuffle(train_data)
        loss = 0.
        for raw_text, entity_offsets in train_data:
            gold = GoldParse(doc, entities=entity_offsets)
            // By default, the GoldParse class assumes that the entities
            // described by offset are complete, and all other words should
            // have the tag "O". You can tell it to make no assumptions
            // about the tag of a word by giving it the tag "-".

After Change


def train_ner(nlp, train_data, output_dir):
    random.seed(0)
    optimizer = nlp.begin_training(lambda: [])
    nlp.meta["name"] = "en_ent_animal"
    for itn in range(50):
        losses = {}
        for batch in minibatch(get_gold_parses(nlp.make_doc, train_data), size=3):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: explosion/spaCy
Commit Name: 683d81bb49096867f5ad8d3dde23217ea54d6790
Time: 2017-09-14
Author: honnibal+gh@gmail.com
File Name: examples/training/train_new_entity_type.py
Class Name:
Method Name: train_ner


Project Name: explosion/spaCy
Commit Name: fe498b3d5e1e29fb756c203d50e217e8f258e561
Time: 2017-11-06
Author: ines@ines.io
File Name: examples/training/train_ner.py
Class Name:
Method Name: main


Project Name: explosion/spaCy
Commit Name: 8e7414daceed0a4f9d58dd12ad2f22be7f0097be
Time: 2019-10-27
Author: svlandeg@users.noreply.github.com
File Name: examples/training/ner_multitask_objective.py
Class Name:
Method Name: main