Skip to content

Commit

Permalink
Merge branch 'develop' into group
Browse files Browse the repository at this point in the history
  • Loading branch information
luotao1 committed Nov 15, 2016
2 parents 0752b3b + 9115ab1 commit ffbf00a
Show file tree
Hide file tree
Showing 63 changed files with 5,295 additions and 4,981 deletions.
5 changes: 2 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
# The document of clang-format is
# http://clang.llvm.org/docs/ClangFormat.html
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
# TODO(yuyang18): Add python and other language code style
---
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
TabWidth: 2
ContinuationIndentWidth: 4
AccessModifierOffset: -2 # The private/protected/public has no indent in class
PointerAlignment: Left # int* p/int& p, not int *p/int &p
Standard: Cpp11
AllowAllParametersOfDeclarationOnNextLine: true
BinPackParameters: false
BinPackArguments: false
...

24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
sha: c25201a00e6b0514370501050cf2a8538ac12270
hooks:
- id: remove-crlf
- repo: https://github.com/reyoung/mirrors-yapf.git
sha: v0.13.2
hooks:
- id: yapf
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: 4ef03c4223ad322c7adaa6c6c0efb26b57df3b71
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
# TODO(yuyang): trailing whitespace has some bugs on markdown
# files now, please not add it to pre-commit hook now
# - id: trailing-whitespace
#
# TODO(yuyang): debug-statements not fit for Paddle, because
# not all of our python code is runnable. Some are used for
# documenation
# - id: debug-statements
1 change: 0 additions & 1 deletion demo/introduction/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
This folder contains scripts used in PaddlePaddle introduction.
- use `bash train.sh` to train a simple linear regression model
- use `python evaluate_model.py` to read model parameters. You can see that `w` and `b` are very close to [2, 0.3].

1 change: 0 additions & 1 deletion demo/mnist/data/get_mnist_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ done
cd $DIR
rm -f *.list
python generate_list.py

1 change: 0 additions & 1 deletion demo/recommendation/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
"fields": ["id", "title", "genres"]
}
}

1 change: 0 additions & 1 deletion demo/semantic_role_labeling/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ paddle train \
--use_gpu=false \
--config_args=is_test=1 \
2>&1 | tee 'test.log'

1 change: 0 additions & 1 deletion demo/semantic_role_labeling/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ paddle train \
--show_parameter_stats_period=10 \
--test_all_data_in_one_period=1 \
2>&1 | tee 'train.log'

366 changes: 183 additions & 183 deletions doc/demo/semantic_role_labeling/semantic_role_labeling.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ User Guide
* [Build and Installation](build/index.rst)
* [Contribute Code](build/contribute_to_paddle.md)
* [User Interface](ui/index.md)
* [Model Config Interface](ui/api/trainer_config_helpers/index.md)
* [Model Config Interface](ui/api/trainer_config_helpers/index.rst)
* [Example and Demo](demo/index.md)
* [Cluster Train](cluster/index.md)

Expand Down
1 change: 0 additions & 1 deletion doc/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ There, you have recovered the underlying pattern between `X` and `Y` only from o
- <a href="../build/index.html"> Build and Installation </a>
- <a href="../demo/quick_start/index_en.html">Quick Start</a>
- <a href="../demo/index.html">Example and Demo</a>

5 changes: 4 additions & 1 deletion doc/ui/api/trainer_config_helpers/activations.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
===========
Activations
===========

BaseActivation
==============

Expand Down Expand Up @@ -102,4 +106,3 @@ STanhActivation
.. automodule:: paddle.trainer_config_helpers.activations
:members: STanhActivation
:noindex:

7 changes: 0 additions & 7 deletions doc/ui/api/trainer_config_helpers/activations_index.rst

This file was deleted.

4 changes: 4 additions & 0 deletions doc/ui/api/trainer_config_helpers/evaluators.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
==========
Evaluators
==========

Base
====
.. automodule:: paddle.trainer_config_helpers.evaluators
Expand Down
7 changes: 0 additions & 7 deletions doc/ui/api/trainer_config_helpers/evaluators_index.rst

This file was deleted.

10 changes: 0 additions & 10 deletions doc/ui/api/trainer_config_helpers/index.md

This file was deleted.

14 changes: 14 additions & 0 deletions doc/ui/api/trainer_config_helpers/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Model Config Interface
======================

.. toctree::
:maxdepth: 1

optimizers.rst
data_sources.rst
layers.rst
activations.rst
poolings.rst
networks.rst
evaluators.rst
attrs.rst
12 changes: 11 additions & 1 deletion doc/ui/api/trainer_config_helpers/layers.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
======
Layers
======

Base
======

Expand Down Expand Up @@ -47,7 +51,7 @@ conv_operator
:noindex:

conv_projection
-------------
---------------
.. automodule:: paddle.trainer_config_helpers.layers
:members: conv_projection
:noindex:
Expand Down Expand Up @@ -187,6 +191,12 @@ embedding_layer
:members: embedding_layer
:noindex:

scaling_projection
-----------------
.. automodule:: paddle.trainer_config_helpers.layers
:members: scaling_projection
:noindex:

dotmul_projection
-----------------
.. automodule:: paddle.trainer_config_helpers.layers
Expand Down
7 changes: 0 additions & 7 deletions doc/ui/api/trainer_config_helpers/layers_index.rst

This file was deleted.

7 changes: 6 additions & 1 deletion doc/ui/api/trainer_config_helpers/networks.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
========
Networks
========

The networks module contains pieces of neural network that combine multiple layers.

NLP
===

Expand Down Expand Up @@ -111,4 +117,3 @@ outputs
.. automodule:: paddle.trainer_config_helpers.networks
:members: outputs
:noindex:

9 changes: 0 additions & 9 deletions doc/ui/api/trainer_config_helpers/networks_index.rst

This file was deleted.

5 changes: 4 additions & 1 deletion doc/ui/api/trainer_config_helpers/optimizers.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
==========
Optimizers
==========

BaseSGDOptimizer
================
.. automodule:: paddle.trainer_config_helpers.optimizers
Expand Down Expand Up @@ -51,4 +55,3 @@ settings
.. automodule:: paddle.trainer_config_helpers.optimizers
:members: settings
:noindex:

7 changes: 0 additions & 7 deletions doc/ui/api/trainer_config_helpers/optimizers_index.rst

This file was deleted.

5 changes: 4 additions & 1 deletion doc/ui/api/trainer_config_helpers/poolings.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
========
Poolings
========

BasePoolingType
===============
.. automodule:: paddle.trainer_config_helpers.poolings
Expand Down Expand Up @@ -27,4 +31,3 @@ SquareRootNPooling
.. automodule:: paddle.trainer_config_helpers.poolings
:members: SquareRootNPooling
:noindex:

9 changes: 0 additions & 9 deletions doc/ui/api/trainer_config_helpers/poolings_index.rst

This file was deleted.

132 changes: 66 additions & 66 deletions doc_cn/algorithm/rnn/hierarchical-layer.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
# 支持双层序列作为输入的Layer

## 概述

在自然语言处理任务中,序列是一种常见的数据类型。一个独立的词语,可以看作是一个非序列输入,或者,我们称之为一个0层的序列;由词语构成的句子,是一个单层序列;若干个句子构成一个段落,是一个双层的序列。

双层序列是一个嵌套的序列,它的每一个元素,又是一个单层的序列。这是一种非常灵活的数据组织方式,帮助我们构造一些复杂的输入信息。

我们可以按照如下层次定义非序列,单层序列,以及双层序列。

+ 0层序列:一个独立的元素,类型可以是PaddlePaddle支持的任意输入数据类型
+ 单层序列:排成一列的多个元素,每个元素是一个0层序列,元素之间的顺序是重要的输入信息
+ 双层序列:排成一列的多个元素,每个元素是一个单层序列,称之为双层序列的一个子序列(subseq),subseq的每个元素是一个0层序列


在 PaddlePaddle中,下面这些Layer能够接受双层序列作为输入,完成相应的计算。
## pooling_layer

pooling_layer的使用示例如下,详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#pooling-layer">配置API</a>。
```python
seq_pool = pooling_layer(input=layer,
pooling_type=AvgPooling(),
agg_level=AggregateLevel.EACH_SEQUENCE)
```
- `pooling_type` 目前支持两种,分别是:MaxPooling()和AvgPooling()。
- `agg_level=AggregateLevel.TIMESTEP`时(默认值):
- 作用:双层序列经过运算变成一个0层序列,或单层序列经过运算变成一个0层序列
- 输入:一个双层序列,或一个单层序列
- 输出:一个0层序列,即整个输入序列(单层或双层)的平均值(或最大值)
- `agg_level=AggregateLevel.EACH_SEQUENCE`时:
- 作用:一个双层序列经过运算变成一个单层序列
- 输入:必须是一个双层序列
- 输出:一个单层序列,序列的每个元素是原来双层序列每个subseq元素的平均值(或最大值)

## last_seq 和 first_seq

last_seq的使用示例如下(first_seq类似),详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#last-seq">配置API</a>。
```python
last = last_seq(input=layer,
agg_level=AggregateLevel.EACH_SEQUENCE)
```
- `agg_level=AggregateLevel.TIMESTEP`时(默认值):
- 作用:一个双层序列经过运算变成一个0层序列,或一个单层序列经过运算变成一个0层序列
- 输入:一个双层序列或一个单层序列
- 输出:一个0层序列,即整个输入序列(双层或者单层)最后一个,或第一个元素。
- `agg_level=AggregateLevel.EACH_SEQUENCE`时:
- 作用:一个双层序列经过运算变成一个单层序列
- 输入:必须是一个双层序列
- 输出:一个单层序列,其中每个元素是双层序列中每个subseq最后一个(或第一个)元素。

## expand_layer

expand_layer的使用示例如下,详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#expand-layer">配置API</a>。
```python
expand = expand_layer(input=layer1,
expand_as=layer2,
expand_level=ExpandLevel.FROM_TIMESTEP)
```
- `expand_level=ExpandLevel.FROM_TIMESTEP`时(默认值):
- 作用:一个0层序列经过运算扩展成一个单层序列,或者一个双层序列
- 输入:layer1必须是一个0层序列,是待扩展的数据;layer2可以是一个单层序列,或者是一个双层序列,提供扩展的长度信息
- 输出:一个单层序列,或一个双层序列,输出序列的类型(双层序列,或单层序列)和序列中含有元素的数目同 layer2一致。若输出是单层序列,单层序列的每个元素(0层序列),都是对layer1元素的拷贝;若输出是双层序列,双层序列每个subseq中每个元素(0层序列),都是对layer1元素的拷贝
- `expand_level=ExpandLevel.FROM_SEQUENCE`时:
- 作用:一个单层序列经过运算扩展成一个双层序列
- 输入:layer1必须是一个单层序列,是待扩展的数据;layer2必须是一个双层序列,提供扩展的长度信息
- 输出:一个双层序列,序列中含有元素的数目同layer2一致。要求单层序列含有元素的数目(0层序列),和双层序列含有subseq 的数目一致。单层序列第i个元素(0层序列),被扩展为一个单层序列,构成了输出双层序列的第i个subseq。
# 支持双层序列作为输入的Layer

## 概述

在自然语言处理任务中,序列是一种常见的数据类型。一个独立的词语,可以看作是一个非序列输入,或者,我们称之为一个0层的序列;由词语构成的句子,是一个单层序列;若干个句子构成一个段落,是一个双层的序列。

双层序列是一个嵌套的序列,它的每一个元素,又是一个单层的序列。这是一种非常灵活的数据组织方式,帮助我们构造一些复杂的输入信息。

我们可以按照如下层次定义非序列,单层序列,以及双层序列。

+ 0层序列:一个独立的元素,类型可以是PaddlePaddle支持的任意输入数据类型
+ 单层序列:排成一列的多个元素,每个元素是一个0层序列,元素之间的顺序是重要的输入信息
+ 双层序列:排成一列的多个元素,每个元素是一个单层序列,称之为双层序列的一个子序列(subseq),subseq的每个元素是一个0层序列


在 PaddlePaddle中,下面这些Layer能够接受双层序列作为输入,完成相应的计算。
## pooling_layer

pooling_layer的使用示例如下,详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#pooling-layer">配置API</a>。
```python
seq_pool = pooling_layer(input=layer,
pooling_type=AvgPooling(),
agg_level=AggregateLevel.EACH_SEQUENCE)
```
- `pooling_type` 目前支持两种,分别是:MaxPooling()和AvgPooling()。
- `agg_level=AggregateLevel.TIMESTEP`时(默认值):
- 作用:双层序列经过运算变成一个0层序列,或单层序列经过运算变成一个0层序列
- 输入:一个双层序列,或一个单层序列
- 输出:一个0层序列,即整个输入序列(单层或双层)的平均值(或最大值)
- `agg_level=AggregateLevel.EACH_SEQUENCE`时:
- 作用:一个双层序列经过运算变成一个单层序列
- 输入:必须是一个双层序列
- 输出:一个单层序列,序列的每个元素是原来双层序列每个subseq元素的平均值(或最大值)

## last_seq 和 first_seq

last_seq的使用示例如下(first_seq类似),详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#last-seq">配置API</a>。
```python
last = last_seq(input=layer,
agg_level=AggregateLevel.EACH_SEQUENCE)
```
- `agg_level=AggregateLevel.TIMESTEP`时(默认值):
- 作用:一个双层序列经过运算变成一个0层序列,或一个单层序列经过运算变成一个0层序列
- 输入:一个双层序列或一个单层序列
- 输出:一个0层序列,即整个输入序列(双层或者单层)最后一个,或第一个元素。
- `agg_level=AggregateLevel.EACH_SEQUENCE`时:
- 作用:一个双层序列经过运算变成一个单层序列
- 输入:必须是一个双层序列
- 输出:一个单层序列,其中每个元素是双层序列中每个subseq最后一个(或第一个)元素。

## expand_layer

expand_layer的使用示例如下,详细见<a href = "../../../doc/ui/api/trainer_config_helpers/layers.html#expand-layer">配置API</a>。
```python
expand = expand_layer(input=layer1,
expand_as=layer2,
expand_level=ExpandLevel.FROM_TIMESTEP)
```
- `expand_level=ExpandLevel.FROM_TIMESTEP`时(默认值):
- 作用:一个0层序列经过运算扩展成一个单层序列,或者一个双层序列
- 输入:layer1必须是一个0层序列,是待扩展的数据;layer2可以是一个单层序列,或者是一个双层序列,提供扩展的长度信息
- 输出:一个单层序列,或一个双层序列,输出序列的类型(双层序列,或单层序列)和序列中含有元素的数目同 layer2一致。若输出是单层序列,单层序列的每个元素(0层序列),都是对layer1元素的拷贝;若输出是双层序列,双层序列每个subseq中每个元素(0层序列),都是对layer1元素的拷贝
- `expand_level=ExpandLevel.FROM_SEQUENCE`时:
- 作用:一个单层序列经过运算扩展成一个双层序列
- 输入:layer1必须是一个单层序列,是待扩展的数据;layer2必须是一个双层序列,提供扩展的长度信息
- 输出:一个双层序列,序列中含有元素的数目同layer2一致。要求单层序列含有元素的数目(0层序列),和双层序列含有subseq 的数目一致。单层序列第i个元素(0层序列),被扩展为一个单层序列,构成了输出双层序列的第i个subseq。
Loading

0 comments on commit ffbf00a

Please sign in to comment.