Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
72209769
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
72209769
编写于
4月 03, 2020
作者:
Z
zhongpu
提交者:
GitHub
4月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix if logic for dygraph, test=develop (#4447)
上级
5678d3f0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
11 deletion
+11
-11
dygraph/bert/model/transformer_encoder.py
dygraph/bert/model/transformer_encoder.py
+2
-2
dygraph/lac/sequence_labeling.py
dygraph/lac/sequence_labeling.py
+3
-3
dygraph/sentiment/nets.py
dygraph/sentiment/nets.py
+2
-2
dygraph/seq2seq/attention_model.py
dygraph/seq2seq/attention_model.py
+1
-1
dygraph/transformer/model.py
dygraph/transformer/model.py
+3
-3
未找到文件。
dygraph/bert/model/transformer_encoder.py
浏览文件 @
72209769
...
...
@@ -37,7 +37,7 @@ class PrePostProcessLayer(Layer):
for
cmd
in
self
.
process_cmd
:
if
cmd
==
"a"
:
# add residual connection
self
.
functors
.
append
(
lambda
x
,
y
:
x
+
y
if
y
else
x
)
self
.
functors
.
append
(
lambda
x
,
y
:
x
+
y
if
y
is
not
None
else
x
)
self
.
exec_order
+=
"a"
elif
cmd
==
"n"
:
# add layer normalization
self
.
functors
.
append
(
...
...
@@ -215,7 +215,7 @@ class MultiHeadAttentionLayer(Layer):
y
=
transpose_k
,
transpose_y
=
True
)
#alpha=self._d_model**-0.5)
if
attn_bias
:
if
attn_bias
is
not
None
:
product
+=
attn_bias
weights
=
fluid
.
layers
.
softmax
(
product
)
if
self
.
_dropout_rate
:
...
...
dygraph/lac/sequence_labeling.py
浏览文件 @
72209769
...
...
@@ -164,7 +164,7 @@ class Linear_chain_crf(fluid.dygraph.Layer):
"Transition"
:
self
.
_transition
,
"Label"
:
[
label
]
}
if
length
:
if
length
is
not
None
:
this_inputs
[
'Length'
]
=
[
length
]
self
.
_helper
.
append_op
(
type
=
'linear_chain_crf'
,
...
...
@@ -212,7 +212,7 @@ class Crf_decoding(fluid.dygraph.Layer):
viterbi_path
=
self
.
_helper
.
create_variable_for_type_inference
(
dtype
=
self
.
_dtype
)
this_inputs
=
{
"Emission"
:
[
input
],
"Transition"
:
self
.
_transition
,
"Label"
:
label
}
if
length
:
if
length
is
not
None
:
this_inputs
[
'Length'
]
=
[
length
]
self
.
_helper
.
append_op
(
type
=
'crf_decoding'
,
...
...
@@ -245,7 +245,7 @@ class Chunk_eval(fluid.dygraph.Layer):
num_correct_chunks
=
self
.
_helper
.
create_variable_for_type_inference
(
dtype
=
"int64"
)
this_input
=
{
"Inference"
:
[
input
],
"Label"
:
[
label
]}
if
seq_length
:
if
seq_length
is
not
None
:
this_input
[
"SeqLength"
]
=
[
seq_length
]
self
.
_helper
.
append_op
(
...
...
dygraph/sentiment/nets.py
浏览文件 @
72209769
...
...
@@ -156,7 +156,7 @@ class BOW(fluid.dygraph.Layer):
fc_1
=
self
.
_fc1
(
bow_1
)
fc_2
=
self
.
_fc2
(
fc_1
)
prediction
=
self
.
_fc_prediction
(
fc_2
)
if
label
:
if
label
is
not
None
:
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
avg_cost
=
fluid
.
layers
.
mean
(
x
=
cost
)
acc
=
fluid
.
layers
.
accuracy
(
input
=
prediction
,
label
=
label
)
...
...
@@ -258,4 +258,4 @@ class BiGRU(fluid.dygraph.Layer):
acc
=
fluid
.
layers
.
accuracy
(
input
=
prediction
,
label
=
label
)
return
avg_cost
,
prediction
,
acc
else
:
return
prediction
\ No newline at end of file
return
prediction
dygraph/seq2seq/attention_model.py
浏览文件 @
72209769
...
...
@@ -169,7 +169,7 @@ class AttentionModel(fluid.dygraph.Layer):
memory
=
self
.
attn_fc
(
enc_output
)
attn
=
fluid
.
layers
.
matmul
(
query
,
memory
,
transpose_y
=
True
)
if
mask
:
if
mask
is
not
None
:
attn
=
fluid
.
layers
.
transpose
(
attn
,
[
1
,
0
,
2
])
attn
=
fluid
.
layers
.
elementwise_add
(
attn
,
mask
*
1000000000
,
-
1
)
attn
=
fluid
.
layers
.
transpose
(
attn
,
[
1
,
0
,
2
])
...
...
dygraph/transformer/model.py
浏览文件 @
72209769
...
...
@@ -78,7 +78,7 @@ class PrePostProcessLayer(Layer):
self
.
functors
=
[]
for
cmd
in
self
.
process_cmd
:
if
cmd
==
"a"
:
# add residual connection
self
.
functors
.
append
(
lambda
x
,
y
:
x
+
y
if
y
else
x
)
self
.
functors
.
append
(
lambda
x
,
y
:
x
+
y
if
y
is
not
None
else
x
)
elif
cmd
==
"n"
:
# add layer normalization
self
.
functors
.
append
(
self
.
add_sublayer
(
...
...
@@ -156,7 +156,7 @@ class MultiHeadAttention(Layer):
y
=
k
,
transpose_y
=
True
,
alpha
=
self
.
d_model
**-
0.5
)
if
attn_bias
:
if
attn_bias
is
not
None
:
product
+=
attn_bias
weights
=
layers
.
softmax
(
product
)
if
self
.
dropout_rate
:
...
...
@@ -936,4 +936,4 @@ class Transformer(Layer):
layers
.
gather_tree
(
predict_ids
,
parent_ids
),
[
1
,
2
,
0
])
finished_scores
=
topk_scores
return
finished_seq
,
finished_scores
\ No newline at end of file
return
finished_seq
,
finished_scores
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录