Closed windweller closed 6 years ago
I think you saved only the encoder. And so you loaded the encoder instead of the full model, and then you are trying to forward the ((s1_batch, s1_len), (s2_batch, s2_len)) tuple to the "forward" function of the encoder, while it is meant to be fed to the "forward" function of the full model.
Since InferSent is meant to use only the sentence encoder, I did not save the classifier at the end of train_nli.py ( https://github.com/facebookresearch/InferSent/blob/master/train_nli.py#L303 ) . I will make a slight modification so that it saves both.
Can I just change it to:
torch.save(nli_net,
os.path.join(params.outputdir, params.outputmodelname))
?
https://github.com/facebookresearch/InferSent/commit/bcc794990d40774698ab492d29396721ae0b2f9c should fix it. Then you load either: os.path.join(params.outputdir, params.outputmodelname) : full model (encoder + classifier) os.path.join(params.outputdir, params.outputmodelname + '.encoder')) : just the encoder
Cool, thanks :)
Hi,
I'm using PyTorch 0.2.0 I trained a model using this code's default setting already, and just want to reload it and evaluate it on validation and test dataset.
However, I encountered this error:
Is this a PyTorch version-related error? I didn't change any code except commenting out the training part.