Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
901b6ffb
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
901b6ffb
编写于
12月 04, 2017
作者:
W
wangmeng28
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/develop' into restructure_ltr
上级
65e8a7e8
3417627f
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
28 addition
and
19 deletion
+28
-19
conv_seq2seq/beamsearch.py
conv_seq2seq/beamsearch.py
+0
-1
generate_sequence_by_rnn_lm/network_conf.py
generate_sequence_by_rnn_lm/network_conf.py
+1
-1
generate_sequence_by_rnn_lm/train.py
generate_sequence_by_rnn_lm/train.py
+6
-1
nested_sequence/text_classification/network_conf.py
nested_sequence/text_classification/network_conf.py
+4
-2
sequence_tagging_for_ner/network_conf.py
sequence_tagging_for_ner/network_conf.py
+13
-10
sequence_tagging_for_ner/train.py
sequence_tagging_for_ner/train.py
+4
-4
未找到文件。
conv_seq2seq/beamsearch.py
浏览文件 @
901b6ffb
...
...
@@ -11,7 +11,6 @@ import reader
class
BeamSearch
(
object
):
"""
Generate sequence by beam search
NOTE: this class only implements generating one sentence at a time.
"""
def
__init__
(
self
,
...
...
generate_sequence_by_rnn_lm/network_conf.py
浏览文件 @
901b6ffb
...
...
@@ -57,4 +57,4 @@ def rnn_lm(vocab_dim,
else
:
cost
=
paddle
.
layer
.
classification_cost
(
input
=
output
,
label
=
target
)
return
cost
,
output
return
cost
generate_sequence_by_rnn_lm/train.py
浏览文件 @
901b6ffb
...
...
@@ -43,9 +43,14 @@ def train(topology,
# create parameters
parameters
=
paddle
.
parameters
.
create
(
topology
)
# create sum evaluator
sum_eval
=
paddle
.
evaluator
.
sum
(
topology
)
# create trainer
trainer
=
paddle
.
trainer
.
SGD
(
cost
=
topology
,
parameters
=
parameters
,
update_equation
=
adam_optimizer
)
cost
=
topology
,
parameters
=
parameters
,
update_equation
=
adam_optimizer
,
extra_layers
=
sum_eval
)
# define the event_handler callback
def
event_handler
(
event
):
...
...
nested_sequence/text_classification/network_conf.py
浏览文件 @
901b6ffb
...
...
@@ -15,11 +15,13 @@ def cnn_cov_group(group_input, hidden_size):
conv4
=
paddle
.
networks
.
sequence_conv_pool
(
input
=
group_input
,
context_len
=
4
,
hidden_size
=
hidden_size
)
fc_param_attr
=
paddle
.
attr
.
ParamAttr
(
name
=
'_cov_value_weight'
)
fc_bias_attr
=
paddle
.
attr
.
ParamAttr
(
name
=
'_cov_value_bias'
)
linear_proj
=
paddle
.
layer
.
fc
(
input
=
[
conv3
,
conv4
],
size
=
hidden_size
,
param_attr
=
paddle
.
attr
.
ParamAttr
(
name
=
'_cov_value_weight'
)
,
bias_attr
=
paddle
.
attr
.
ParamAttr
(
name
=
'_cov_value_bias'
)
,
param_attr
=
[
fc_param_attr
,
fc_param_attr
]
,
bias_attr
=
fc_bias_attr
,
act
=
paddle
.
activation
.
Linear
())
return
linear_proj
...
...
sequence_tagging_for_ner/network_conf.py
浏览文件 @
901b6ffb
...
...
@@ -8,7 +8,7 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
mark_dict_len
=
2
word_dim
=
50
mark_dim
=
5
hidden_dim
=
128
hidden_dim
=
300
word
=
paddle
.
layer
.
data
(
name
=
"word"
,
...
...
@@ -23,9 +23,7 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
name
=
"mark"
,
type
=
paddle
.
data_type
.
integer_value_sequence
(
mark_dict_len
))
mark_embedding
=
paddle
.
layer
.
embedding
(
input
=
mark
,
size
=
mark_dim
,
param_attr
=
paddle
.
attr
.
Param
(
initial_std
=
math
.
sqrt
(
1.
/
word_dim
)))
input
=
mark
,
size
=
mark_dim
,
param_attr
=
paddle
.
attr
.
Param
(
initial_std
=
0.
))
word_caps_vector
=
paddle
.
layer
.
concat
(
input
=
[
word_embedding
,
mark_embedding
])
...
...
@@ -33,7 +31,7 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
mix_hidden_lr
=
1e-3
rnn_para_attr
=
paddle
.
attr
.
Param
(
initial_std
=
0.0
,
learning_rate
=
0.1
)
hidden_para_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1
/
math
.
sqrt
(
hidden_dim
)
,
learning_rate
=
mix_hidden_lr
)
initial_std
=
1
.
/
math
.
sqrt
(
hidden_dim
)
/
3
,
learning_rate
=
mix_hidden_lr
)
# the first forward and backward rnn layer share the
# input-to-hidden mappings.
...
...
@@ -41,9 +39,10 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
name
=
"__hidden00__"
,
size
=
hidden_dim
,
act
=
paddle
.
activation
.
Tanh
(),
bias_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
),
bias_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
/
math
.
sqrt
(
hidden_dim
)
/
3
),
input
=
word_caps_vector
,
param_attr
=
hidden_para_attr
)
param_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
/
math
.
sqrt
(
hidden_dim
)
/
3
))
fea
=
[]
for
direction
in
[
"fwd"
,
"bwd"
]:
...
...
@@ -68,7 +67,7 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
rnn_fea
=
paddle
.
layer
.
fc
(
size
=
hidden_dim
,
bias_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
),
bias_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
/
math
.
sqrt
(
hidden_dim
)
/
3
),
act
=
paddle
.
activation
.
STanh
(),
input
=
fea
,
param_attr
=
[
hidden_para_attr
,
rnn_para_attr
]
*
2
)
...
...
@@ -85,7 +84,8 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
bias_attr
=
False
,
input
=
rnn_fea
,
act
=
paddle
.
activation
.
Linear
(),
param_attr
=
rnn_para_attr
)
param_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1.
/
math
.
sqrt
(
hidden_dim
)
/
3
))
if
is_train
:
target
=
paddle
.
layer
.
data
(
...
...
@@ -96,7 +96,10 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
size
=
label_dict_len
,
input
=
emission
,
label
=
target
,
param_attr
=
paddle
.
attr
.
Param
(
name
=
"crfw"
,
initial_std
=
1e-3
))
param_attr
=
paddle
.
attr
.
Param
(
name
=
"crfw"
,
initial_std
=
1.
/
math
.
sqrt
(
hidden_dim
)
/
3
,
learning_rate
=
mix_hidden_lr
))
crf_dec
=
paddle
.
layer
.
crf_decoding
(
size
=
label_dict_len
,
...
...
sequence_tagging_for_ner/train.py
浏览文件 @
901b6ffb
...
...
@@ -16,8 +16,8 @@ def main(train_data_file,
target_file
,
emb_file
,
model_save_dir
,
num_passes
=
10
,
batch_size
=
32
):
num_passes
=
10
0
,
batch_size
=
64
):
if
not
os
.
path
.
exists
(
model_save_dir
):
os
.
mkdir
(
model_save_dir
)
...
...
@@ -75,10 +75,10 @@ def main(train_data_file,
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
1
==
0
:
if
event
.
batch_id
%
5
==
0
:
logger
.
info
(
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
))
if
event
.
batch_id
%
1
==
0
:
if
event
.
batch_id
%
50
==
0
:
result
=
trainer
.
test
(
reader
=
test_reader
,
feeding
=
feeding
)
logger
.
info
(
"
\n
Test with Pass %d, Batch %d, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
result
.
metrics
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录