Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
368d16c1
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看板
未验证
提交
368d16c1
编写于
11月 16, 2017
作者:
C
Cao Ying
提交者:
GitHub
11月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #473 from lcy-seso/fix_ner
fix a bug of NER that emission feature uses an unexpected nonlinear activation.
上级
c952c3de
5bb22517
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
9 deletion
+19
-9
sequence_tagging_for_ner/data/vocab.txt
sequence_tagging_for_ner/data/vocab.txt
+1
-1
sequence_tagging_for_ner/network_conf.py
sequence_tagging_for_ner/network_conf.py
+17
-8
sequence_tagging_for_ner/train.py
sequence_tagging_for_ner/train.py
+1
-0
未找到文件。
sequence_tagging_for_ner/data/vocab.txt
浏览文件 @
368d16c1
<UNK>
UUUNKKK
the
,
.
...
...
sequence_tagging_for_ner/network_conf.py
浏览文件 @
368d16c1
...
...
@@ -11,16 +11,16 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
hidden_dim
=
128
word
=
paddle
.
layer
.
data
(
name
=
'word'
,
name
=
"word"
,
type
=
paddle
.
data_type
.
integer_value_sequence
(
word_dict_len
))
word_embedding
=
paddle
.
layer
.
embedding
(
input
=
word
,
size
=
word_dim
,
param_attr
=
paddle
.
attr
.
Param
(
name
=
'emb'
,
initial_std
=
math
.
sqrt
(
1.
/
word_dim
),
is_static
=
True
))
name
=
"emb"
,
initial_std
=
math
.
sqrt
(
1.
/
word_dim
),
is_static
=
True
))
mark
=
paddle
.
layer
.
data
(
name
=
'mark'
,
name
=
"mark"
,
type
=
paddle
.
data_type
.
integer_value_sequence
(
mark_dict_len
))
mark_embedding
=
paddle
.
layer
.
embedding
(
input
=
mark
,
...
...
@@ -35,7 +35,8 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
hidden_para_attr
=
paddle
.
attr
.
Param
(
initial_std
=
1
/
math
.
sqrt
(
hidden_dim
),
learning_rate
=
mix_hidden_lr
)
# the first rnn layer shares the input-to-hidden mappings.
# the first forward and backward rnn layer share the
# input-to-hidden mappings.
hidden
=
paddle
.
layer
.
fc
(
name
=
"__hidden00__"
,
size
=
hidden_dim
,
...
...
@@ -72,32 +73,40 @@ def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
input
=
fea
,
param_attr
=
[
hidden_para_attr
,
rnn_para_attr
]
*
2
)
# NOTE: This fully connected layer calculates the emission feature for
# the CRF layer. Because the paddle.layer.crf performs global normalization
# over all possible sequences internally, it expects UNSCALED emission
# feature weights.
# Please do not add any nonlinear activation to this fully connected layer.
# The default activation for paddle.layer.fc is the tanh, here needs to set
# it to linear explictly.
emission
=
paddle
.
layer
.
fc
(
size
=
label_dict_len
,
bias_attr
=
False
,
input
=
rnn_fea
,
act
=
paddle
.
activation
.
Linear
(),
param_attr
=
rnn_para_attr
)
if
is_train
:
target
=
paddle
.
layer
.
data
(
name
=
'target'
,
name
=
"target"
,
type
=
paddle
.
data_type
.
integer_value_sequence
(
label_dict_len
))
crf
=
paddle
.
layer
.
crf
(
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
=
1e-3
))
crf_dec
=
paddle
.
layer
.
crf_decoding
(
size
=
label_dict_len
,
input
=
emission
,
label
=
target
,
param_attr
=
paddle
.
attr
.
Param
(
name
=
'crfw'
))
param_attr
=
paddle
.
attr
.
Param
(
name
=
"crfw"
))
return
crf
,
crf_dec
,
target
else
:
predict
=
paddle
.
layer
.
crf_decoding
(
size
=
label_dict_len
,
input
=
emission
,
param_attr
=
paddle
.
attr
.
Param
(
name
=
'crfw'
))
param_attr
=
paddle
.
attr
.
Param
(
name
=
"crfw"
))
return
predict
sequence_tagging_for_ner/train.py
浏览文件 @
368d16c1
import
os
import
gzip
import
numpy
as
np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录