You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_elmo_embedding.py 578 B

123456789101112131415161718192021
  1. import unittest
  2. from fastNLP import Vocabulary
  3. from fastNLP.embeddings import ElmoEmbedding
  4. import torch
  5. import os
  6. @unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
  7. class TestDownload(unittest.TestCase):
  8. def test_download_small(self):
  9. # import os
  10. vocab = Vocabulary().add_word_lst("This is a test .".split())
  11. elmo_embed = ElmoEmbedding(vocab, model_dir_or_name='en-small')
  12. words = torch.LongTensor([[0, 1, 2]])
  13. print(elmo_embed(words).size())
  14. # 首先保证所有权重可以加载;上传权重;验证可以下载