From b8dbff987b0169b641518165f3c25ca7ccb74055 Mon Sep 17 00:00:00 2001 From: Steffy-zxf <48793257+Steffy-zxf@users.noreply.github.com> Date: Tue, 26 May 2020 10:26:35 +0800 Subject: [PATCH] update docs (#619) * update docs --- RELEASE.md | 4 ++-- demo/text_classification/README.md | 1 + docs/reference/task/text_classify_task.md | 2 +- docs/release.md | 4 ++-- paddlehub/network/classification.py | 12 ++++++------ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 9ca73e86..8c8a7a08 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,9 +5,9 @@ * 新增工业级短视频分类模型[videotag_tsn_lstm](https://paddlepaddle.org.cn/hubdetail?name=videotag_tsn_lstm&en_category=VideoClassification),支持3000类中文标签识别 * 新增轻量级中文OCR模型[chinese_ocr_db_rcnn](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_ocr_db_rcnn&en_category=TextRecognition)、[chinese_text_detection_db](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_text_detection_db&en_category=TextRecognition),支持一键快速OCR识别 * 新增行人检测、车辆检测、动物识别、Object等工业级模型 - + * Fine-tune API升级 - * 文本分类任务新增6个预置网络,包括CNN, BOW, LSTM, BiLSTM, DPCNN等 + * 文本分类任务新增6个预置网络,包括CNN, BOW, LSTM, BiLSTM, DPCNN等 * 使用VisualDL可视化训练评估性能数据 ## `v1.6.2` diff --git a/demo/text_classification/README.md b/demo/text_classification/README.md index 9fed9317..7e3c7c64 100644 --- a/demo/text_classification/README.md +++ b/demo/text_classification/README.md @@ -195,6 +195,7 @@ cls_task.finetune_and_eval() 如果不使用预置网络,直接通过fc网络进行分类,则应取Transformer类预训练模型的pooled_output特征(`outputs["pooled_output"]`)。并且`hub.TextClassifierTask(feature=outputs["pooled_output"])`。 5. 使用预置网络,可以通过`hub.TextClassifierTask`参数network进行指定不同的网络结构。如下代码表示选择bilstm网络拼接在Transformer类预训练模型之后。 PaddleHub文本分类任务预置网络支持BOW,Bi-LSTM,CNN,DPCNN,GRU,LSTM。指定network应是其中之一。 + 其中DPCNN网络实现为[ACL2017-Deep Pyramid Convolutional Neural Networks for Text Categorization](https://www.aclweb.org/anthology/P17-1052.pdf)。 ```python cls_task = hub.TextClassifierTask( data_reader=reader, diff --git a/docs/reference/task/text_classify_task.md b/docs/reference/task/text_classify_task.md index f52268d0..9501cfcd 100644 --- a/docs/reference/task/text_classify_task.md +++ b/docs/reference/task/text_classify_task.md @@ -21,7 +21,7 @@ hub.TextClassifierTask( * data_reader: 提供数据的Reader,可选为ClassifyReader和LACClassifyReader。 * feature(fluid.Variable): 输入的sentence-level特征矩阵,shape应为[-1, emb_size]。默认为None。 * token_feature(fluid.Variable): 输入的token-level特征矩阵,shape应为[-1, seq_len, emb_size]。默认为None。feature和token_feature须指定其中一个。 -* network(str): 文本分类任务PaddleHub预置网络,支持BOW,Bi-LSTM,CNN,DPCNN,GRU,LSTM。如果指定network,则应使用token_feature作为输入特征。 +* network(str): 文本分类任务PaddleHub预置网络,支持BOW,Bi-LSTM,CNN,DPCNN,GRU,LSTM。如果指定network,则应使用token_feature作为输入特征。其中DPCNN网络实现为[ACL2017-Deep Pyramid Convolutional Neural Networks for Text Categorization](https://www.aclweb.org/anthology/P17-1052.pdf)。 * startup_program (fluid.Program): 存储了模型参数初始化op的Program,如果未提供,则使用fluid.default_startup_program() * config ([RunConfig](../config.md)): 运行配置,如设置batch_size,epoch,learning_rate等。 * hidden_units (list): TextClassifierTask最终的全连接层输出维度为label_size,是每个label的概率值。在这个全连接层之前可以设置额外的全连接层,并指定它们的输出维度,例如hidden_units=[4,2]表示先经过一层输出维度为4的全连接层,再输入一层输出维度为2的全连接层,最后再输入输出维度为label_size的全连接层。 diff --git a/docs/release.md b/docs/release.md index 0f0e3a52..9a59ba48 100644 --- a/docs/release.md +++ b/docs/release.md @@ -7,9 +7,9 @@ * 新增工业级短视频分类模型[videotag_tsn_lstm](https://paddlepaddle.org.cn/hubdetail?name=videotag_tsn_lstm&en_category=VideoClassification),支持3000类中文标签识别 * 新增轻量级中文OCR模型[chinese_ocr_db_rcnn](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_ocr_db_rcnn&en_category=TextRecognition)、[chinese_text_detection_db](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_text_detection_db&en_category=TextRecognition),支持一键快速OCR识别 * 新增行人检测、车辆检测、动物识别、Object等工业级模型 - + * Fine-tune API升级 - * 文本分类任务新增6个预置网络,包括CNN, BOW, LSTM, BiLSTM, DPCNN等 + * 文本分类任务新增6个预置网络,包括CNN, BOW, LSTM, BiLSTM, DPCNN等 * 使用VisualDL可视化训练评估性能数据 ## `v1.6.2` diff --git a/paddlehub/network/classification.py b/paddlehub/network/classification.py index 498f29d3..c4412465 100644 --- a/paddlehub/network/classification.py +++ b/paddlehub/network/classification.py @@ -22,7 +22,7 @@ import paddle.fluid as fluid def bilstm(token_embeddings, hid_dim=128, hid_dim2=96): """ - bilstm net + BiLSTM network. """ fc0 = fluid.layers.fc(input=token_embeddings, size=hid_dim * 4) rfc0 = fluid.layers.fc(input=token_embeddings, size=hid_dim * 4) @@ -44,7 +44,7 @@ def bilstm(token_embeddings, hid_dim=128, hid_dim2=96): def bow(token_embeddings, hid_dim=128, hid_dim2=96): """ - bow net + BOW network. """ # bow layer bow = fluid.layers.sequence_pool(input=token_embeddings, pool_type='sum') @@ -57,7 +57,7 @@ def bow(token_embeddings, hid_dim=128, hid_dim2=96): def cnn(token_embeddings, hid_dim=128, win_size=3): """ - cnn net + CNN network. """ # cnn layer conv = fluid.nets.sequence_conv_pool( @@ -77,7 +77,7 @@ def dpcnn(token_embeddings, emb_dim=1024, blocks=6): """ - deepcnn net implemented as ACL2017 'Deep Pyramid Convolutional Neural Networks for Text Categorization' + Deep Pyramid Convolutional Neural Networks is implemented as ACL2017 'Deep Pyramid Convolutional Neural Networks for Text Categorization' For more information, please refer to https://www.aclweb.org/anthology/P17-1052.pdf. """ @@ -111,7 +111,7 @@ def dpcnn(token_embeddings, def gru(token_embeddings, hid_dim=128, hid_dim2=96): """ - gru net + GRU network. """ fc0 = fluid.layers.fc(input=token_embeddings, size=hid_dim * 3) gru_h = fluid.layers.dynamic_gru(input=fc0, size=hid_dim, is_reverse=False) @@ -123,7 +123,7 @@ def gru(token_embeddings, hid_dim=128, hid_dim2=96): def lstm(token_embeddings, hid_dim=128, hid_dim2=96): """ - lstm net + LSTM network. """ # lstm layer fc0 = fluid.layers.fc(input=token_embeddings, size=hid_dim * 4) -- GitLab