Browse Source

修改了 modules 和 models 开篇介绍

tags/v0.4.10
ChenXin 6 years ago
parent
commit
208cf5facb
6 changed files with 66 additions and 15 deletions
  1. +3
    -3
      docs/source/index.rst
  2. +6
    -2
      fastNLP/models/__init__.py
  3. +36
    -4
      fastNLP/modules/__init__.py
  4. +8
    -1
      fastNLP/modules/aggregator/__init__.py
  5. +7
    -1
      fastNLP/modules/decoder/__init__.py
  6. +6
    -4
      fastNLP/modules/encoder/__init__.py

+ 3
- 3
docs/source/index.rst View File

@@ -15,12 +15,12 @@ fastNLP 是一款轻量级的 NLP 处理套件。你既可以使用它快速地
内置组件
------------

大部分用于的 NLP 任务神经网络都可以看做由编码(encoder)、聚合(aggregator)、解码(decoder)三模块组成。
大部分用于的 NLP 任务神经网络都可以看做由编码(encoder)、聚合(aggregator)、解码(decoder)三模块组成。

.. image:: figures/text_classification.png

fastNLP 在 :mod:`~fastNLP.modules` 模块中内置了三模块的诸多组件,可以帮助用户快速搭建自己所需的网络。
模块的功能和常见组件如下:
fastNLP 在 :mod:`~fastNLP.modules` 模块中内置了三模块的诸多组件,可以帮助用户快速搭建自己所需的网络。
模块的功能和常见组件如下:

+-----------------------+-----------------------+-----------------------+
| module type | functionality | example |


+ 6
- 2
fastNLP/models/__init__.py View File

@@ -1,6 +1,10 @@
"""
使用 fastNLP 实现的一系列常见模型,具体有:
TODO 详细介绍的表格,与主页相对应
fastNLP 在 :mod:`~fastNLP.models` 模块中内置了如 :class:`~fastNLP.models.CNNText` 、
:class:`~fastNLP.models.SeqLabeling` 等完整的模型,以供用户直接使用。

.. todo::
这些模型的介绍(与主页一致)


"""
__all__ = ["CNNText", "SeqLabeling", "ESIM", "STSeqLabel", "AdvSeqLabel", "STNLICls", "STSeqCls"]


+ 36
- 4
fastNLP/modules/__init__.py View File

@@ -1,10 +1,25 @@
"""
modules 模块是 fastNLP 的重要组成部分,它实现了神经网络构建中常见的组件,
具体包括 TODO
大部分用于的 NLP 任务神经网络都可以看做由编码 :mod:`~fastNLP.modules.encoder` 、
聚合 :mod:`~fastNLP.modules.aggregator` 、解码 :mod:`~fastNLP.modules.decoder` 三种模块组成。

可以和 PyTorch 结合使用?TODO
.. image:: figures/text_classification.png

TODO __all__ 里面多暴露一些
:mod:`~fastNLP.modules` 中实现了 fastNLP 提供的诸多模块组件,可以帮助用户快速搭建自己所需的网络。
三种模块的功能和常见组件如下:

+-----------------------+-----------------------+-----------------------+
| module type | functionality | example |
+=======================+=======================+=======================+
| encoder | 将输入编码为具有具 | embedding, RNN, CNN, |
| | 有表示能力的向量 | transformer |
+-----------------------+-----------------------+-----------------------+
| aggregator | 从多个向量中聚合信息 | self-attention, |
| | | max-pooling |
+-----------------------+-----------------------+-----------------------+
| decoder | 将具有某种表示意义的 | MLP, CRF |
| | 向量解码为需要的输出 | |
| | 形式 | |
+-----------------------+-----------------------+-----------------------+

"""
from . import aggregator
@@ -16,3 +31,20 @@ from .dropout import TimestepDropout
from .encoder import *
from .utils import get_embeddings

__all__ = [
"LSTM",
"Embedding",
"ConvMaxpool",
"BertModel",
"MaxPool",
"MaxPoolWithMask",
"AvgPool",
"MultiHeadAttention",
"BiAttention",

"MLP",
"ConditionalRandomField",
"viterbi_decode",
"allowed_transitions",
]

+ 8
- 1
fastNLP/modules/aggregator/__init__.py View File

@@ -1,7 +1,14 @@
__all__ = ["MaxPool", "MaxPoolWithMask", "AvgPool", "MultiHeadAttention", "BiAttention"]
from .pooling import MaxPool
from .pooling import MaxPoolWithMask
from .pooling import AvgPool
from .pooling import MeanPoolWithMask

from .attention import MultiHeadAttention, BiAttention
__all__ = [
"MaxPool",
"MaxPoolWithMask",
"AvgPool",
"MultiHeadAttention",
"BiAttention"
]

+ 7
- 1
fastNLP/modules/decoder/__init__.py View File

@@ -1,5 +1,11 @@
__all__ = ["MLP", "ConditionalRandomField", "viterbi_decode", "allowed_transitions"]
from .CRF import ConditionalRandomField
from .MLP import MLP
from .utils import viterbi_decode
from .CRF import allowed_transitions

__all__ = [
"MLP",
"ConditionalRandomField",
"viterbi_decode",
"allowed_transitions"
]

+ 6
- 4
fastNLP/modules/encoder/__init__.py View File

@@ -3,7 +3,9 @@ from .embedding import Embedding
from .lstm import LSTM
from .bert import BertModel

__all__ = ["LSTM",
"Embedding",
"ConvMaxpool",
"BertModel"]
__all__ = [
"LSTM",
"Embedding",
"ConvMaxpool",
"BertModel"
]

Loading…
Cancel
Save