Browse Source

Update char_embedding.py

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

+ 6
- 0
fastNLP/embeddings/char_embedding.py View File

@@ -24,6 +24,9 @@ class CNNCharEmbedding(TokenEmbedding):

Example::

>>> import torch
>>> from fastNLP import Vocabulary
>>> from fastNLP.embeddings import CNNCharEmbedding
>>> vocab = Vocabulary().add_word_lst("The whether is good .".split())
>>> embed = CNNCharEmbedding(vocab, embed_size=50)
>>> words = torch.LongTensor([[vocab.to_index(word) for word in "The whether is good .".split()]])
@@ -167,6 +170,9 @@ class LSTMCharEmbedding(TokenEmbedding):

Example::

>>> import torch
>>> from fastNLP import Vocabulary
>>> from fastNLP.embeddings import LSTMCharEmbedding
>>> vocab = Vocabulary().add_word_lst("The whether is good .".split())
>>> embed = LSTMCharEmbedding(vocab, embed_size=50)
>>> words = torch.LongTensor([[vocab.to_index(word) for word in "The whether is good .".split()]])


Loading…
Cancel
Save