diff options
| author | zhang <zch921005@126.com> | 2022-07-03 12:49:17 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2022-07-03 12:49:17 +0800 |
| commit | 8131406d83acad62de49ad51f219b3d2dba562d8 (patch) | |
| tree | 223b630dcd131bbd1d1e061a3c45dd719f2238eb /fine_tune/input_output.py | |
| parent | 8c1d5025e8a7c341ea651821222229ca75cd8208 (diff) | |
torch.no_grad vs. requires_grad
Diffstat (limited to 'fine_tune/input_output.py')
| -rw-r--r-- | fine_tune/input_output.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fine_tune/input_output.py b/fine_tune/input_output.py new file mode 100644 index 0000000..684ded5 --- /dev/null +++ b/fine_tune/input_output.py @@ -0,0 +1,13 @@ + +from transformers import BertModel, BertTokenizer + +model_name = 'bert-base-uncased' + +tokenizer = BertTokenizer.from_pretrained(model_name) +model = BertModel.from_pretrained(model_name) + +raw_sentences = ['Tom likes cats', 'Liz likes dogs'] + +inputs = tokenizer.encode_plus(raw_sentences[0], raw_sentences[1], return_tensors='pt') +# inputs = tokenizer('Hello, my dog is cute', return_tensors='pt') +model(**inputs) |
