Browse Source

Update bert_embedding.py

tags/v0.4.10
zide05 GitHub 6 years ago
parent
commit
31f35ad617
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions
  1. +1
    -0
      fastNLP/embeddings/bert_embedding.py

+ 1
- 0
fastNLP/embeddings/bert_embedding.py View File

@@ -27,6 +27,7 @@ class BertEmbedding(ContextualEmbedding):

>>> import torch
>>> from fastNLP import Vocabulary
>>> from fastNLP.embeddings import BertEmbedding
>>> vocab = Vocabulary().add_word_lst("The whether is good .".split())
>>> embed = BertEmbedding(vocab, model_dir_or_name='en-base-uncased', requires_grad=False, layers='4,-2,-1')
>>> words = torch.LongTensor([[vocab.to_index(word) for word in "The whether is good .".split()]])


Loading…
Cancel
Save