简体   繁体   English

如何从检查点加载 simpletransformers model?

[英]How do you load a simpletransformers model from a checkpoint?

I'm using simpletransformers ( https://github.com/ThilinaRajapakse/simpletransformers ) for a work project.我正在为一个工作项目使用 simpletransformers ( https://github.com/ThilinaRajapakse/simpletransformers )。 After training a model, I get a bunch of files dumped to the output folder.在训练 model 后,我得到一堆文件转储到 output 文件夹中。 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?我想知道,如果您想加载先前训练过的 model(我假设它已保存到 output 文件夹中),以便您可以立即针对新数据运行它,那么 Z34D1F91FB2E514B8576FAB1A75A 会怎么做? Picture of files in output folder output文件夹中的文件图片

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?使用 scikit-learn,您可以轻松地将模型导出到 json,然后将它们重新加载,我想可能有类似的过程?

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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