diff options
| author | zhang <zch921005@126.com> | 2022-07-10 11:00:10 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2022-07-10 11:00:10 +0800 |
| commit | e0208fc250d4c8ae4d42f44ffddf151237211877 (patch) | |
| tree | 2914c95e4351fa15154c6b6a600a3fa9bd59c0d1 /fine_tune/bert/tutorials/05_output.py | |
| parent | 677ba817b2be8d720cc567b364a369ff91a90b95 (diff) | |
wordpiece
Diffstat (limited to 'fine_tune/bert/tutorials/05_output.py')
| -rw-r--r-- | fine_tune/bert/tutorials/05_output.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fine_tune/bert/tutorials/05_output.py b/fine_tune/bert/tutorials/05_output.py new file mode 100644 index 0000000..1911641 --- /dev/null +++ b/fine_tune/bert/tutorials/05_output.py @@ -0,0 +1,25 @@ +from transformers import BertModel, BertTokenizer +from transformers.models.bert import BertModel +import torch +from torch import nn + + +if __name__ == '__main__': + + model_name = 'bert-base-uncased' + + tokenizer = BertTokenizer.from_pretrained(model_name) + model = BertModel.from_pretrained(model_name, output_hidden_states=True) + + text = "After stealing money from the bank vault, the bank robber was seen " \ + "fishing on the Mississippi river bank." + + + token_inputs = tokenizer(text, return_tensors='pt') + with torch.no_grad(): + outputs = model(**token_inputs) + + + + + |
