diff --git a/fastNLP/modules/__init__.py b/fastNLP/modules/__init__.py index 43ec3f5f..7b0237dc 100644 --- a/fastNLP/modules/__init__.py +++ b/fastNLP/modules/__init__.py @@ -1,22 +1,19 @@ """ -大部分用于的 NLP 任务神经网络都可以看做由编码 :mod:`~fastNLP.modules.encoder` 、 -解码 :mod:`~fastNLP.modules.decoder` 两种模块组成。 .. image:: figures/text_classification.png -:mod:`~fastNLP.modules` 中实现了 fastNLP 提供的诸多模块组件,可以帮助用户快速搭建自己所需的网络。 -两种模块的功能和常见组件如下: +大部分用于的 NLP 任务神经网络都可以看做由 :mod:`embedding` 、 :mod:`~fastNLP.modules.encoder` 、 +:mod:`~fastNLP.modules.decoder` 三种模块组成。 本模块中实现了 fastNLP 提供的诸多模块组件, +可以帮助用户快速搭建自己所需的网络。几种模块的功能和常见组件如下: + +.. csv-table:: + :header: "类型", "功能", "常见组件" + + "embedding", 参见 :doc:`fastNLP.embeddings` , "Elmo, Bert" + "encoder", "将输入编码为具有表示能力的向量", "CNN, LSTM, Transformer" + "decoder", "将具有某种表示意义的向量解码为需要的输出形式 ", "MLP, CRF" + "其它", "配合其它组件使用的组件", "Dropout" -+-----------------------+-----------------------+-----------------------+ -| module type | functionality | example | -+=======================+=======================+=======================+ -| encoder | 将输入编码为具有具 | embedding, RNN, CNN, | -| | 有表示能力的向量 | transformer | -+-----------------------+-----------------------+-----------------------+ -| decoder | 将具有某种表示意义的 | MLP, CRF | -| | 向量解码为需要的输出 | | -| | 形式 | | -+-----------------------+-----------------------+-----------------------+ """ __all__ = [ @@ -40,6 +37,8 @@ __all__ = [ "ConditionalRandomField", "viterbi_decode", "allowed_transitions", + + "TimestepDropout", ] from . import decoder diff --git a/fastNLP/modules/dropout.py b/fastNLP/modules/dropout.py index 1363165c..0ea2a2d9 100644 --- a/fastNLP/modules/dropout.py +++ b/fastNLP/modules/dropout.py @@ -5,10 +5,8 @@ import torch class TimestepDropout(torch.nn.Dropout): """ - 别名::class:`fastNLP.modules.TimestepDropout` - - 接受的参数shape为``[batch_size, num_timesteps, embedding_dim)]`` 使用同一个mask(shape为``(batch_size, embedding_dim)``) - 在每个timestamp上做dropout。 + 传入参数的shape为 ``(batch_size, num_timesteps, embedding_dim)`` + 使用同一个shape为 ``(batch_size, embedding_dim)`` 的mask在每个timestamp上做dropout。 """ def forward(self, x):