Skip to content

Save & Package a custom PyTorch model #2292

Answered by s-bernard
s-bernard asked this question in Q&A
Discussion options

You must be logged in to vote

I understood why my output did not have "last_hidden_state". It’s because I was loading my model in Python with BertModel.from_pretrained("bert-base-uncased", torchscript=True) which define a tuple as output instead of a dict with the names.

By removing the torchscript=True and using strict=False in torch.jit.trace, it works as expected.

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by s-bernard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants