@@ -0,0 +1,7 @@ | |||||
fastNLP.component.bert\_tokenizer module | |||||
======================================== | |||||
.. automodule:: fastNLP.component.bert_tokenizer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,15 @@ | |||||
fastNLP.component package | |||||
========================= | |||||
.. automodule:: fastNLP.component | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.component.bert_tokenizer | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.batch module | |||||
========================= | |||||
.. automodule:: fastNLP.core.batch | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.callback module | |||||
============================ | |||||
.. automodule:: fastNLP.core.callback | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.const module | |||||
========================= | |||||
.. automodule:: fastNLP.core.const | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.dataset module | |||||
=========================== | |||||
.. automodule:: fastNLP.core.dataset | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.field module | |||||
========================= | |||||
.. automodule:: fastNLP.core.field | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.instance module | |||||
============================ | |||||
.. automodule:: fastNLP.core.instance | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.losses module | |||||
========================== | |||||
.. automodule:: fastNLP.core.losses | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.metrics module | |||||
=========================== | |||||
.. automodule:: fastNLP.core.metrics | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.optimizer module | |||||
============================= | |||||
.. automodule:: fastNLP.core.optimizer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,28 @@ | |||||
fastNLP.core package | |||||
==================== | |||||
.. automodule:: fastNLP.core | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.core.batch | |||||
fastNLP.core.callback | |||||
fastNLP.core.const | |||||
fastNLP.core.dataset | |||||
fastNLP.core.field | |||||
fastNLP.core.instance | |||||
fastNLP.core.losses | |||||
fastNLP.core.metrics | |||||
fastNLP.core.optimizer | |||||
fastNLP.core.sampler | |||||
fastNLP.core.tester | |||||
fastNLP.core.trainer | |||||
fastNLP.core.utils | |||||
fastNLP.core.vocabulary | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.sampler module | |||||
=========================== | |||||
.. automodule:: fastNLP.core.sampler | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.tester module | |||||
========================== | |||||
.. automodule:: fastNLP.core.tester | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.trainer module | |||||
=========================== | |||||
.. automodule:: fastNLP.core.trainer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.utils module | |||||
========================= | |||||
.. automodule:: fastNLP.core.utils | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.core.vocabulary module | |||||
============================== | |||||
.. automodule:: fastNLP.core.vocabulary | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.base\_loader module | |||||
============================== | |||||
.. automodule:: fastNLP.io.base_loader | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.config\_io module | |||||
============================ | |||||
.. automodule:: fastNLP.io.config_io | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.dataset\_loader module | |||||
================================= | |||||
.. automodule:: fastNLP.io.dataset_loader | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.embed\_loader module | |||||
=============================== | |||||
.. automodule:: fastNLP.io.embed_loader | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.file\_reader module | |||||
============================== | |||||
.. automodule:: fastNLP.io.file_reader | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.io.model\_io module | |||||
=========================== | |||||
.. automodule:: fastNLP.io.model_io | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,20 @@ | |||||
fastNLP.io package | |||||
================== | |||||
.. automodule:: fastNLP.io | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.io.base_loader | |||||
fastNLP.io.config_io | |||||
fastNLP.io.dataset_loader | |||||
fastNLP.io.embed_loader | |||||
fastNLP.io.file_reader | |||||
fastNLP.io.model_io | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.base\_model module | |||||
================================= | |||||
.. automodule:: fastNLP.models.base_model | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.bert module | |||||
========================== | |||||
.. automodule:: fastNLP.models.bert | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.biaffine\_parser module | |||||
====================================== | |||||
.. automodule:: fastNLP.models.biaffine_parser | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.char\_language\_model module | |||||
=========================================== | |||||
.. automodule:: fastNLP.models.char_language_model | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.cnn\_text\_classification module | |||||
=============================================== | |||||
.. automodule:: fastNLP.models.cnn_text_classification | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.enas\_controller module | |||||
====================================== | |||||
.. automodule:: fastNLP.models.enas_controller | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.enas\_model module | |||||
================================= | |||||
.. automodule:: fastNLP.models.enas_model | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.enas\_trainer module | |||||
=================================== | |||||
.. automodule:: fastNLP.models.enas_trainer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.enas\_utils module | |||||
================================= | |||||
.. automodule:: fastNLP.models.enas_utils | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,26 @@ | |||||
fastNLP.models package | |||||
====================== | |||||
.. automodule:: fastNLP.models | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.models.base_model | |||||
fastNLP.models.bert | |||||
fastNLP.models.biaffine_parser | |||||
fastNLP.models.char_language_model | |||||
fastNLP.models.cnn_text_classification | |||||
fastNLP.models.enas_controller | |||||
fastNLP.models.enas_model | |||||
fastNLP.models.enas_trainer | |||||
fastNLP.models.enas_utils | |||||
fastNLP.models.sequence_modeling | |||||
fastNLP.models.snli | |||||
fastNLP.models.star_transformer | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.sequence\_modeling module | |||||
======================================== | |||||
.. automodule:: fastNLP.models.sequence_modeling | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.snli module | |||||
========================== | |||||
.. automodule:: fastNLP.models.snli | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.models.star\_transformer module | |||||
======================================= | |||||
.. automodule:: fastNLP.models.star_transformer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.aggregator.attention module | |||||
=========================================== | |||||
.. automodule:: fastNLP.modules.aggregator.attention | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.aggregator.pooling module | |||||
========================================= | |||||
.. automodule:: fastNLP.modules.aggregator.pooling | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,16 @@ | |||||
fastNLP.modules.aggregator package | |||||
================================== | |||||
.. automodule:: fastNLP.modules.aggregator | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.modules.aggregator.attention | |||||
fastNLP.modules.aggregator.pooling | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.decoder.CRF module | |||||
================================== | |||||
.. automodule:: fastNLP.modules.decoder.CRF | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.decoder.MLP module | |||||
================================== | |||||
.. automodule:: fastNLP.modules.decoder.MLP | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,17 @@ | |||||
fastNLP.modules.decoder package | |||||
=============================== | |||||
.. automodule:: fastNLP.modules.decoder | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.modules.decoder.CRF | |||||
fastNLP.modules.decoder.MLP | |||||
fastNLP.modules.decoder.utils | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.decoder.utils module | |||||
==================================== | |||||
.. automodule:: fastNLP.modules.decoder.utils | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.dropout module | |||||
============================== | |||||
.. automodule:: fastNLP.modules.dropout | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.bert module | |||||
=================================== | |||||
.. automodule:: fastNLP.modules.encoder.bert | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.char\_encoder module | |||||
============================================ | |||||
.. automodule:: fastNLP.modules.encoder.char_encoder | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.conv\_maxpool module | |||||
============================================ | |||||
.. automodule:: fastNLP.modules.encoder.conv_maxpool | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.embedding module | |||||
======================================== | |||||
.. automodule:: fastNLP.modules.encoder.embedding | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.linear module | |||||
===================================== | |||||
.. automodule:: fastNLP.modules.encoder.linear | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.lstm module | |||||
=================================== | |||||
.. automodule:: fastNLP.modules.encoder.lstm | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,23 @@ | |||||
fastNLP.modules.encoder package | |||||
=============================== | |||||
.. automodule:: fastNLP.modules.encoder | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Submodules | |||||
---------- | |||||
.. toctree:: | |||||
fastNLP.modules.encoder.bert | |||||
fastNLP.modules.encoder.char_encoder | |||||
fastNLP.modules.encoder.conv_maxpool | |||||
fastNLP.modules.encoder.embedding | |||||
fastNLP.modules.encoder.linear | |||||
fastNLP.modules.encoder.lstm | |||||
fastNLP.modules.encoder.star_transformer | |||||
fastNLP.modules.encoder.transformer | |||||
fastNLP.modules.encoder.variational_rnn | |||||
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.star\_transformer module | |||||
================================================ | |||||
.. automodule:: fastNLP.modules.encoder.star_transformer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.transformer module | |||||
========================================== | |||||
.. automodule:: fastNLP.modules.encoder.transformer | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.encoder.variational\_rnn module | |||||
=============================================== | |||||
.. automodule:: fastNLP.modules.encoder.variational_rnn | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.other\_modules module | |||||
===================================== | |||||
.. automodule:: fastNLP.modules.other_modules | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,18 @@ | |||||
fastNLP.modules package | |||||
======================= | |||||
.. automodule:: fastNLP.modules | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Subpackages | |||||
----------- | |||||
.. toctree:: | |||||
fastNLP.modules.aggregator | |||||
fastNLP.modules.decoder | |||||
fastNLP.modules.encoder |
@@ -0,0 +1,7 @@ | |||||
fastNLP.modules.utils module | |||||
============================ | |||||
.. automodule:: fastNLP.modules.utils | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: |
@@ -0,0 +1,19 @@ | |||||
fastNLP package | |||||
=============== | |||||
.. automodule:: fastNLP | |||||
:members: | |||||
:undoc-members: | |||||
:show-inheritance: | |||||
Subpackages | |||||
----------- | |||||
.. toctree:: | |||||
fastNLP.component | |||||
fastNLP.core | |||||
fastNLP.io | |||||
fastNLP.models | |||||
fastNLP.modules | |||||
@@ -1,13 +1,21 @@ | |||||
fastNLP documentation | |||||
fastNLP 中文文档 | |||||
===================== | ===================== | ||||
A Modularized and Extensible Toolkit for Natural Language Processing. Currently still in incubation. | |||||
fastNLP 是一款轻量级的 NLP 处理套件。你既可以使用它快速地完成一个命名实体识别(NER)、中文分词或文本分类任务; | |||||
也可以使用他构建许多复杂的网络模型,进行科研。它具有如下的特性: | |||||
Introduction | |||||
- 代码简洁易懂,有着详尽的中文文档以供查阅; | |||||
- 深度学习的各个阶段划分明确,配合 fitlog 使用让科研更轻松; | |||||
- 内置多种常见模型 (TODO); | |||||
- 基于 PyTorch ,方便从原生 PyTorch 代码迁入,并能使用 PyTorch 中的各种组件; | |||||
- 便于 seq2seq; | |||||
- 便于 fine-tune | |||||
内置的模块 | |||||
------------ | ------------ | ||||
FastNLP is a modular Natural Language Processing system based on | |||||
PyTorch, built for fast development of NLP models. | |||||
(TODO) | |||||
A deep learning NLP model is the composition of three types of modules: | A deep learning NLP model is the composition of three types of modules: | ||||
@@ -33,31 +41,41 @@ For example: | |||||
各个任务上的结果 | |||||
----------------------- | |||||
(TODO) | |||||
快速入门 | |||||
------------- | |||||
TODO | |||||
用户手册 | |||||
--------------- | |||||
User's Guide | |||||
------------ | |||||
.. toctree:: | .. toctree:: | ||||
:maxdepth: 2 | |||||
:maxdepth: 1 | |||||
user/installation | |||||
user/quickstart | |||||
安装指南 <user/installation> | |||||
快速入门 <user/quickstart> | |||||
使用 fastNLP 分类 <user/task1> | |||||
使用 fastNLP 分词 <user/task2> | |||||
API Reference | |||||
API 文档 | |||||
------------- | ------------- | ||||
If you are looking for information on a specific function, class or | |||||
method, this part of the documentation is for you. | |||||
除了用户手册之外,你还可以通过查阅 API 文档来找到你所需要的工具。 | |||||
.. toctree:: | .. toctree:: | ||||
:maxdepth: 2 | :maxdepth: 2 | ||||
fastNLP API <fastNLP> | |||||
fastNLP | |||||
Indices and tables | |||||
索引与搜索 | |||||
================== | ================== | ||||
* :ref:`genindex` | * :ref:`genindex` | ||||
@@ -0,0 +1,7 @@ | |||||
fastNLP | |||||
======= | |||||
.. toctree:: | |||||
:maxdepth: 4 | |||||
fastNLP |
@@ -1,17 +1,21 @@ | |||||
============ | |||||
Installation | |||||
============ | |||||
=============== | |||||
安装指南 | |||||
=============== | |||||
.. contents:: | .. contents:: | ||||
:local: | :local: | ||||
Make sure your environment satisfies https://github.com/fastnlp/fastNLP/blob/master/requirements.txt . | |||||
fastNLP 依赖如下包:: | |||||
Run the following commands to install fastNLP package: | |||||
torch>=0.4.0 | |||||
numpy | |||||
tensorboardX | |||||
tqdm | |||||
nltk | |||||
.. code:: shell | |||||
pip install fastNLP | |||||
其中torch的安装可能与操作系统及 CUDA 的版本相关,请参见 `PyTorch 官网 <https://pytorch.org/get-started/locally/>`_ 。 | |||||
在依赖包安装完成的情况,您可以在命令行执行如下指令完成安装 | |||||
.. code:: shell | |||||
>>> pip install fitlog |
@@ -1,11 +1,3 @@ | |||||
Quickstart | |||||
========== | |||||
.. toctree:: | |||||
:maxdepth: 1 | |||||
../tutorials/fastnlp_1_minute_tutorial | |||||
../tutorials/fastnlp_10tmin_tutorial | |||||
../tutorials/fastnlp_advanced_tutorial | |||||
../tutorials/fastnlp_developer_guide | |||||
=============== | |||||
快速入门 | |||||
=============== |
@@ -0,0 +1,3 @@ | |||||
===================== | |||||
用 fastNLP 分词 | |||||
===================== |
@@ -1,5 +1,14 @@ | |||||
""" | """ | ||||
fastNLP 由 :mod:`~fastNLP.core` 、 :mod:`~fastNLP.io` 、:mod:`~fastNLP.modules` 等子模块组成,但常用的组件都可以直接 import ,常用组件如下: | |||||
fastNLP 由 :mod:`~fastNLP.core` 、 :mod:`~fastNLP.io` 、:mod:`~fastNLP.modules`、:mod:`~fastNLP.models` | |||||
和 :mod:`~fastNLP.component` 等子模块组成。 | |||||
- :mod:`~fastNLP.core` fastNLP 的核心模块,包括 DataSet、 Trainer、 Tester 等组件 | |||||
- :mod:`~fastNLP.io` fastNLP 的输入输出模块,实现了数据集的读取,模型的存取等功能 | |||||
- :mod:`~fastNLP.modules` TODO 如何介绍 | |||||
- :mod:`~fastNLP.models` 使用 fastNLP 实现的一些常见模型,具体参见 :doc:`fastNLP.models` | |||||
- :mod:`~fastNLP.component` TODO | |||||
fastNLP 中最常用的组件可以直接从 fastNLP 包中 import ,他们的文档如下: | |||||
""" | """ | ||||
__all__ = ["Instance", "FieldArray", "Batch", "Vocabulary", "DataSet", | __all__ = ["Instance", "FieldArray", "Batch", "Vocabulary", "DataSet", | ||||
"Trainer", "Tester", "Callback", | "Trainer", "Tester", "Callback", | ||||
@@ -1,3 +1,8 @@ | |||||
""" | |||||
使用 fastNLP 实现的一系列常见模型,具体有: | |||||
TODO 详细介绍的表格,与主页相对应 | |||||
""" | |||||
from .base_model import BaseModel | from .base_model import BaseModel | ||||
from .biaffine_parser import BiaffineParser, GraphParser | from .biaffine_parser import BiaffineParser, GraphParser | ||||
from .char_language_model import CharLM | from .char_language_model import CharLM | ||||
@@ -12,6 +12,14 @@ class CNNText(torch.nn.Module): | |||||
""" | """ | ||||
使用CNN进行文本分类的模型 | 使用CNN进行文本分类的模型 | ||||
'Yoon Kim. 2014. Convolution Neural Networks for Sentence Classification.' | 'Yoon Kim. 2014. Convolution Neural Networks for Sentence Classification.' | ||||
:param tuple(int,int),torch.FloatTensor,nn.Embedding,numpy.ndarray init_embed: Embedding的大小(传入tuple(int, int), | |||||
第一个int为vocab_zie, 第二个int为embed_dim); 如果为Tensor, Embedding, ndarray等则直接使用该值初始化Embedding | |||||
:param int num_classes: 一共有多少类 | |||||
:param int,tuple(int) out_channels: 输出channel的数量。如果为list,则需要与kernel_sizes的数量保持一致 | |||||
:param int,tuple(int) kernel_sizes: 输出channel的kernel大小。 | |||||
:param int padding: | |||||
:param float dropout: Dropout的大小 | |||||
""" | """ | ||||
def __init__(self, init_embed, | def __init__(self, init_embed, | ||||
@@ -20,16 +28,6 @@ class CNNText(torch.nn.Module): | |||||
kernel_sizes=(3, 4, 5), | kernel_sizes=(3, 4, 5), | ||||
padding=0, | padding=0, | ||||
dropout=0.5): | dropout=0.5): | ||||
""" | |||||
:param tuple(int,int),torch.FloatTensor,nn.Embedding,numpy.ndarray init_embed: Embedding的大小(传入tuple(int, int), | |||||
第一个int为vocab_zie, 第二个int为embed_dim); 如果为Tensor, Embedding, ndarray等则直接使用该值初始化Embedding | |||||
:param int num_classes: 一共有多少类 | |||||
:param int,tuple(int) out_channels: 输出channel的数量。如果为list,则需要与kernel_sizes的数量保持一致 | |||||
:param int,tuple(int) kernel_sizes: 输出channel的kernel大小。 | |||||
:param int padding: | |||||
:param float dropout: Dropout的大小 | |||||
""" | |||||
super(CNNText, self).__init__() | super(CNNText, self).__init__() | ||||
# no support for pre-trained embedding currently | # no support for pre-trained embedding currently | ||||
@@ -1,13 +1,19 @@ | |||||
""" | |||||
modules 模块是 fastNLP 的重要组成部分,它实现了神经网络构建中常见的组件, | |||||
具体包括 TODO | |||||
可以和 PyTorch 结合使用?TODO | |||||
TODO __all__ 里面多暴露一些 | |||||
""" | |||||
from . import aggregator | from . import aggregator | ||||
from . import decoder | from . import decoder | ||||
from . import encoder | from . import encoder | ||||
from .aggregator import * | from .aggregator import * | ||||
from .decoder import * | from .decoder import * | ||||
from .other_modules import * | |||||
from .dropout import TimestepDropout | from .dropout import TimestepDropout | ||||
from .encoder import * | from .encoder import * | ||||
__version__ = '0.0.0' | __version__ = '0.0.0' | ||||
__all__ = ['encoder', | |||||
'decoder', | |||||
'aggregator'] |
@@ -1,3 +1,5 @@ | |||||
__all__ = ["MaxPool", "MaxPoolWithMask", "AvgPool", "MeanPoolWithMask", "KMaxPool", "Attention", "BiAttention", | |||||
"SelfAttention"] | |||||
from .pooling import MaxPool | from .pooling import MaxPool | ||||
from .pooling import MaxPoolWithMask | from .pooling import MaxPoolWithMask | ||||
from .pooling import AvgPool | from .pooling import AvgPool | ||||
@@ -7,4 +9,3 @@ from .pooling import KMaxPool | |||||
from .attention import Attention | from .attention import Attention | ||||
from .attention import BiAttention | from .attention import BiAttention | ||||
from .attention import SelfAttention | from .attention import SelfAttention | ||||
@@ -117,11 +117,11 @@ class BiAttention(nn.Module): | |||||
.. math:: | .. math:: | ||||
\begin{array}{ll} \\ | |||||
e_ij = {a}^{\mathbf{T}}_{i}{b}_{j} \\ | |||||
\\begin{array}{ll} \\\\ | |||||
e_ij = {a}^{\\mathbf{T}}_{i}{b}_{j} \\\\ | |||||
a_i = | a_i = | ||||
b_j = | b_j = | ||||
\end{array} | |||||
\\end{array} | |||||
""" | """ | ||||
@@ -144,18 +144,19 @@ def _is_transition_allowed(encoding_type, from_tag, from_label, to_tag, to_label | |||||
class ConditionalRandomField(nn.Module): | class ConditionalRandomField(nn.Module): | ||||
"""条件随机场。 | |||||
提供forward()以及viterbi_decode()两个方法,分别用于训练与inference。 | |||||
:param int num_tags: 标签的数量 | |||||
:param bool include_start_end_trans: 是否考虑各个tag作为开始以及结尾的分数。 | |||||
:param List[Tuple[from_tag_id(int), to_tag_id(int)]] allowed_transitions: 内部的Tuple[from_tag_id(int), | |||||
to_tag_id(int)]视为允许发生的跃迁,其他没有包含的跃迁认为是禁止跃迁,可以通过 | |||||
allowed_transitions()函数得到;如果为None,则所有跃迁均为合法 | |||||
:param str initial_method: 初始化方法。见initial_parameter | |||||
""" | |||||
def __init__(self, num_tags, include_start_end_trans=False, allowed_transitions=None, | def __init__(self, num_tags, include_start_end_trans=False, allowed_transitions=None, | ||||
initial_method=None): | initial_method=None): | ||||
"""条件随机场。 | |||||
提供forward()以及viterbi_decode()两个方法,分别用于训练与inference。 | |||||
:param int num_tags: 标签的数量 | |||||
:param bool include_start_end_trans: 是否考虑各个tag作为开始以及结尾的分数。 | |||||
:param List[Tuple[from_tag_id(int), to_tag_id(int)]] allowed_transitions: 内部的Tuple[from_tag_id(int), | |||||
to_tag_id(int)]视为允许发生的跃迁,其他没有包含的跃迁认为是禁止跃迁,可以通过 | |||||
allowed_transitions()函数得到;如果为None,则所有跃迁均为合法 | |||||
:param str initial_method: 初始化方法。见initial_parameter | |||||
""" | |||||
super(ConditionalRandomField, self).__init__() | super(ConditionalRandomField, self).__init__() | ||||
self.include_start_end_trans = include_start_end_trans | self.include_start_end_trans = include_start_end_trans | ||||
@@ -1,2 +1,3 @@ | |||||
__all__ = ["MLP", "ConditionalRandomField"] | |||||
from .CRF import ConditionalRandomField | from .CRF import ConditionalRandomField | ||||
from .MLP import MLP | from .MLP import MLP |