MatchZoo-py icon indicating copy to clipboard operation
MatchZoo-py copied to clipboard

How to load a pretrained model?

Open czt616 opened this issue 4 years ago • 3 comments

After using trainer.save() to save the model. How can I load this model and evaluate it? Thanks!

czt616 avatar Jan 08 '20 15:01 czt616

trainer = mz.trainers.Trainer(..., checkpoint=\path\to\your\saved\model)

RenShuhuai-Andy avatar Jan 16 '20 03:01 RenShuhuai-Andy

@caiyinqiong @Chriskuei Hi~ I have an anthor question about loading pretrained model. When we Instantiate a trainer, it seems that the parameter trainloader and validloader must be passed in with strict type check. To get these two loaders requires inconvenient time for data preprocessing. However, if we just use trainer to predict or evaluate, there is no need to get trainloader and validloader. This seems to be an unreasonable design. Or do you have any idea to solve this problem? Thanks.

RenShuhuai-Andy avatar Jan 17 '20 09:01 RenShuhuai-Andy

@RenShuhuai-Andy I used the code in the tutorial-conv-knrm. And I use trainer.restore_model('./pretrained_cknrm/1/model.pt') print(trainer.evaluate(testloader)) But why I get different result every time?

czt616 avatar Feb 21 '20 08:02 czt616