Open anbo724 opened 3 years ago
Here's one:
import torch
import matchzoo as mz
from anmm_train import *
test_pack = mz.datasets.wiki_qa.load_data('test', task=ranking_task)
test_processed = preprocessor.transform(test_pack, verbose=0)
testset = mz.dataloader.Dataset(
data_pack=test_processed,
mode='point',
batch_size=32
)
testloader = mz.dataloader.DataLoader(
dataset=testset,
device=device,
stage='test',
callback=padding_callback
)
if __name__ == "__main__":
trainer.restore_model("./save/model.pt")
prediction = trainer.predict(testloader)
pass
# end main
, where anmm_train
is the code copied from repo's README, except Trainer.run()
. Though you're in predict stage, the train/test dataset is still required as Trainer
takes them as required parameter to construct.
I have trained the Esim and Bert model. However, I can not found any code for predicting new sentence pair? Is anyone can help?