简体   繁体   中英

How do you load a simpletransformers model from a checkpoint?

I'm using simpletransformers ( https://github.com/ThilinaRajapakse/simpletransformers ) for a work project. After training a model, I get a bunch of files dumped to the output folder. I was wondering, if you wanted to load in a previously trained model (which I assume is saved to the output folder) so that you can immediately run it against new data, how would one go about doing this? Picture of files in output folder

With scikit-learn, you can export models to json easily, and load them back in, I figured there might be a similar process for this?

from simpletransformers.classification import ClassificationModel

model = ClassificationModel("bert", "outputs/best_model")
model.predict(['Enter text to classify'])
model = ClassificationModel(model_name, model_path, num_labels=no_labels)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM