ebanalyse / NERDA

Framework for fine-tuning pretrained transformers for Named-Entity Recognition (NER) tasks
MIT License
154 stars 35 forks source link

question about save model #6

Closed Shengyu-Liu558 closed 3 years ago

Shengyu-Liu558 commented 3 years ago

Hello, How to save the model that I have trained through code?

yptheangel commented 3 years ago

using pytorch syntax,

import torch
modelname = f'your_modelname_here.bin'
torch.save(model.network.state_dict(), modelname )

to load model, model.load_network_from_file(model_path=modelname)

Shengyu-Liu558 commented 3 years ago

When I load the trained model by "model.load_network_from_file(model_path=modelname)",it is error, could I need to change the load code?

Shengyu-Liu558 commented 3 years ago

next quesition

smaakage85 commented 3 years ago

hi @Shengyu-Liu558

With NERDA==1.0.0, see functions:

python model.save_network python model.load_network_from_file

Thank you so much for you feedback.