Browse Source

修改了部分注释

tags/v0.4.10
yh_cc 5 years ago
parent
commit
3b3f550cc5
3 changed files with 12 additions and 4 deletions
  1. +7
    -0
      fastNLP/modules/encoder/embedding.py
  2. +3
    -3
      fastNLP/modules/utils.py
  3. +2
    -1
      setup.py

+ 7
- 0
fastNLP/modules/encoder/embedding.py View File

@@ -41,3 +41,10 @@ class Embedding(nn.Embedding):
""" """
x = super().forward(x) x = super().forward(x)
return self.dropout(x) return self.dropout(x)

def size(self):
"""
Embedding的大小
:return: torch.Size()
"""
return self.weight.size()

+ 3
- 3
fastNLP/modules/utils.py View File

@@ -74,9 +74,9 @@ def get_embeddings(init_embed):
""" """
根据输入的init_embed生成nn.Embedding对象。 根据输入的init_embed生成nn.Embedding对象。


:param init_embed: 单词词典, 可以是 tuple, 包括(num_embedings, embedding_dim), 即
embedding的大小和每个词的维度. 也可以传入 nn.Embedding 对象,
此时就以传入的对象作为embedding
:param init_embed: 可以是 tuple:(num_embedings, embedding_dim), 即embedding的大小和每个词的维度;也可以传入
nn.Embedding 对象, 此时就以传入的对象作为embedding; 传入np.ndarray也行,将使用传入的ndarray作为作为Embedding初始
化; 传入orch.Tensor, 将使用传入的值作为Embedding初始化。
:return nn.Embedding embeddings: :return nn.Embedding embeddings:
""" """
if isinstance(init_embed, tuple): if isinstance(init_embed, tuple):


+ 2
- 1
setup.py View File

@@ -16,7 +16,8 @@ setup(
version='0.4.0', version='0.4.0',
description='fastNLP: Deep Learning Toolkit for NLP, developed by Fudan FastNLP Team', description='fastNLP: Deep Learning Toolkit for NLP, developed by Fudan FastNLP Team',
long_description=readme, long_description=readme,
license=license,
long_description_content_type='text/markdown',
license='Apache License',
author='FudanNLP', author='FudanNLP',
python_requires='>=3.6', python_requires='>=3.6',
packages=find_packages(), packages=find_packages(),


Loading…
Cancel
Save