image2text

Untitled

Aug 16th, 2019
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. LX)
  2.  
  3. import torch
  4.  
  5. from pytorch_transformers import RobertaTokenizer, RobertaForSequenceClassification
  6. # RoBERTa tokenizer and model loaded from saved checkpoint
  7.  
  8. tokenizer = RobertaTokenizer.from_pretrained("roberta-base")
  9.  
  10. model = RobertaForSequenceClassification.from_pretrained("roberta-base")
  11.  
  12. # Sequence encoded with the correct special separation tokens
  13.  
  14. sequence_0 = "Is this Jacksonville?"
  15.  
  16. sequence_1 = "No it is not."
  17.  
  18. input_ids = torch.tensor([tokenizer.encode(sequence_0, sequence_l, add_special_tokens=True)])
  19. # Returns the loss and the associated logits
  20.  
  21. output = model(input_ids)
Advertisement
Add Comment
Please, Sign In to add comment