Load up previously saved NER models in SpaCy v1.1.2

筅森魡賤 提交于 2019-12-23 23:16:58

问题


So whenever I try to load up a previously saved model for SpaCy NER, I get a core dump.

if os.path.isfile( model_path ):
    ner.model.load( model_path )
for itn in range( 5 ):
    random.shuffle( TRAIN_DATA )
    for raw_text, entity_offsets in TRAIN_DATA:
        doc = nlp.make_doc( raw_text )
        gold = GoldParse( doc, entities=entity_offsets )
        ner.update( doc, gold ) # <- Core dump occurs here

Dump report:

7fb1b7459000-7fb1b7499000 rw-p 00000000 00:00 0 [1]    23967 abort (core dumped)

Am I doing/loading it wrong?


回答1:


Edit: Turns out I don't need to load the model in order to update it, all I need to do is remove

if os.path.isfile( model_path ):
    ner.model.load( model_path )

And add

ner.model.dump( model_path )

to the end like so:

for itn in range( 5 ):
random.shuffle( TRAIN_DATA )
for raw_text, entity_offsets in TRAIN_DATA:
    doc = nlp.make_doc( raw_text )
    gold = GoldParse( doc, entities=entity_offsets )
    ner.update( doc, gold ) 
ner.model.dump( model_path )

in order for it to append to the previously saved data. All good!




回答2:


Hmm. There's probably still a bug here, though. Obviously you should be able to write to a pre-loaded model!



来源:https://stackoverflow.com/questions/40209882/load-up-previously-saved-ner-models-in-spacy-v1-1-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!