Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
4ce6770d
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ce6770d
编写于
3月 08, 2017
作者:
G
gangliao
提交者:
GitHub
3月 08, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #173 from hedaoyuan/v2.sentiment
use v2 attr and pooling
上级
3a5ab5d9
535c606c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
24 deletion
+20
-24
understand_sentiment/README.md
understand_sentiment/README.md
+6
-8
understand_sentiment/index.html
understand_sentiment/index.html
+6
-8
understand_sentiment/train.py
understand_sentiment/train.py
+8
-8
未找到文件。
understand_sentiment/README.md
浏览文件 @
4ce6770d
...
...
@@ -110,8 +110,6 @@ Paddle在`dataset/imdb.py`中提实现了imdb数据集的自动下载和读取
```
import sys
import paddle.trainer_config_helpers.attrs as attrs
from paddle.trainer_config_helpers.poolings import MaxPooling
import paddle.v2 as paddle
```
## 配置模型
...
...
@@ -159,11 +157,11 @@ def stacked_lstm_net(input_dim,
"""
assert stacked_num % 2 == 1
layer_attr =
attrs.ExtraLayerAttribute
(drop_rate=0.5)
fc_para_attr =
attrs.ParameterAttribute
(learning_rate=1e-3)
lstm_para_attr =
attrs.ParameterAttribute
(initial_std=0., learning_rate=1.)
layer_attr =
paddle.attr.Extra
(drop_rate=0.5)
fc_para_attr =
paddle.attr.Param
(learning_rate=1e-3)
lstm_para_attr =
paddle.attr.Param
(initial_std=0., learning_rate=1.)
para_attr = [fc_para_attr, lstm_para_attr]
bias_attr =
attrs.ParameterAttribute
(initial_std=0., l2_rate=0.)
bias_attr =
paddle.attr.Param
(initial_std=0., l2_rate=0.)
relu = paddle.activation.Relu()
linear = paddle.activation.Linear()
...
...
@@ -193,8 +191,8 @@ def stacked_lstm_net(input_dim,
layer_attr=layer_attr)
inputs = [fc, lstm]
fc_last = paddle.layer.pooling(input=inputs[0], pooling_type=
MaxPooling
())
lstm_last = paddle.layer.pooling(input=inputs[1], pooling_type=
MaxPooling
())
fc_last = paddle.layer.pooling(input=inputs[0], pooling_type=
paddle.pooling.Max
())
lstm_last = paddle.layer.pooling(input=inputs[1], pooling_type=
paddle.pooling.Max
())
output = paddle.layer.fc(input=[fc_last, lstm_last],
size=class_dim,
act=paddle.activation.Softmax(),
...
...
understand_sentiment/index.html
浏览文件 @
4ce6770d
...
...
@@ -152,8 +152,6 @@ Paddle在`dataset/imdb.py`中提实现了imdb数据集的自动下载和读取
```
import sys
import paddle.trainer_config_helpers.attrs as attrs
from paddle.trainer_config_helpers.poolings import MaxPooling
import paddle.v2 as paddle
```
## 配置模型
...
...
@@ -201,11 +199,11 @@ def stacked_lstm_net(input_dim,
"""
assert stacked_num % 2 == 1
layer_attr =
attrs.ExtraLayerAttribute
(drop_rate=0.5)
fc_para_attr =
attrs.ParameterAttribute
(learning_rate=1e-3)
lstm_para_attr =
attrs.ParameterAttribute
(initial_std=0., learning_rate=1.)
layer_attr =
paddle.attr.Extra
(drop_rate=0.5)
fc_para_attr =
paddle.attr.Param
(learning_rate=1e-3)
lstm_para_attr =
paddle.attr.Param
(initial_std=0., learning_rate=1.)
para_attr = [fc_para_attr, lstm_para_attr]
bias_attr =
attrs.ParameterAttribute
(initial_std=0., l2_rate=0.)
bias_attr =
paddle.attr.Param
(initial_std=0., l2_rate=0.)
relu = paddle.activation.Relu()
linear = paddle.activation.Linear()
...
...
@@ -235,8 +233,8 @@ def stacked_lstm_net(input_dim,
layer_attr=layer_attr)
inputs = [fc, lstm]
fc_last = paddle.layer.pooling(input=inputs[0], pooling_type=
MaxPooling
())
lstm_last = paddle.layer.pooling(input=inputs[1], pooling_type=
MaxPooling
())
fc_last = paddle.layer.pooling(input=inputs[0], pooling_type=
paddle.pooling.Max
())
lstm_last = paddle.layer.pooling(input=inputs[1], pooling_type=
paddle.pooling.Max
())
output = paddle.layer.fc(input=[fc_last, lstm_last],
size=class_dim,
act=paddle.activation.Softmax(),
...
...
understand_sentiment/train.py
浏览文件 @
4ce6770d
...
...
@@ -13,8 +13,6 @@
# limitations under the License.
import
sys
import
paddle.trainer_config_helpers.attrs
as
attrs
from
paddle.trainer_config_helpers.poolings
import
MaxPooling
import
paddle.v2
as
paddle
...
...
@@ -54,11 +52,11 @@ def stacked_lstm_net(input_dim,
"""
assert
stacked_num
%
2
==
1
layer_attr
=
attrs
.
ExtraLayerAttribute
(
drop_rate
=
0.5
)
fc_para_attr
=
attrs
.
ParameterAttribute
(
learning_rate
=
1e-3
)
lstm_para_attr
=
attrs
.
ParameterAttribute
(
initial_std
=
0.
,
learning_rate
=
1.
)
layer_attr
=
paddle
.
attr
.
Extra
(
drop_rate
=
0.5
)
fc_para_attr
=
paddle
.
attr
.
Param
(
learning_rate
=
1e-3
)
lstm_para_attr
=
paddle
.
attr
.
Param
(
initial_std
=
0.
,
learning_rate
=
1.
)
para_attr
=
[
fc_para_attr
,
lstm_para_attr
]
bias_attr
=
attrs
.
ParameterAttribute
(
initial_std
=
0.
,
l2_rate
=
0.
)
bias_attr
=
paddle
.
attr
.
Param
(
initial_std
=
0.
,
l2_rate
=
0.
)
relu
=
paddle
.
activation
.
Relu
()
linear
=
paddle
.
activation
.
Linear
()
...
...
@@ -88,8 +86,10 @@ def stacked_lstm_net(input_dim,
layer_attr
=
layer_attr
)
inputs
=
[
fc
,
lstm
]
fc_last
=
paddle
.
layer
.
pooling
(
input
=
inputs
[
0
],
pooling_type
=
MaxPooling
())
lstm_last
=
paddle
.
layer
.
pooling
(
input
=
inputs
[
1
],
pooling_type
=
MaxPooling
())
fc_last
=
paddle
.
layer
.
pooling
(
input
=
inputs
[
0
],
pooling_type
=
paddle
.
pooling
.
Max
())
lstm_last
=
paddle
.
layer
.
pooling
(
input
=
inputs
[
1
],
pooling_type
=
paddle
.
pooling
.
Max
())
output
=
paddle
.
layer
.
fc
(
input
=
[
fc_last
,
lstm_last
],
size
=
class_dim
,
act
=
paddle
.
activation
.
Softmax
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录