Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PALM
提交
fc69141e
P
PALM
项目概览
PaddlePaddle
/
PALM
通知
4
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PALM
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fc69141e
编写于
11月 26, 2019
作者:
X
xixiaoyao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/PaddlePaddle/PALM
上级
df92bdfc
2fddd896
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
4 deletion
+7
-4
paddlepalm/backbone/utils/transformer.py
paddlepalm/backbone/utils/transformer.py
+1
-0
paddlepalm/task_instance.py
paddlepalm/task_instance.py
+6
-4
未找到文件。
paddlepalm/backbone/utils/transformer.py
浏览文件 @
fc69141e
...
@@ -24,6 +24,7 @@ import paddle.fluid as fluid
...
@@ -24,6 +24,7 @@ import paddle.fluid as fluid
import
paddle.fluid.layers
as
layers
import
paddle.fluid.layers
as
layers
from
paddle.fluid.layer_helper
import
LayerHelper
as
LayerHelper
from
paddle.fluid.layer_helper
import
LayerHelper
as
LayerHelper
from
functools
import
reduce
# py3
def
layer_norm
(
x
,
begin_norm_axis
=
1
,
epsilon
=
1e-6
,
param_attr
=
None
,
bias_attr
=
None
):
def
layer_norm
(
x
,
begin_norm_axis
=
1
,
epsilon
=
1e-6
,
param_attr
=
None
,
bias_attr
=
None
):
helper
=
LayerHelper
(
'layer_norm'
,
**
locals
())
helper
=
LayerHelper
(
'layer_norm'
,
**
locals
())
mean
=
layers
.
reduce_mean
(
x
,
dim
=
begin_norm_axis
,
keep_dim
=
True
)
mean
=
layers
.
reduce_mean
(
x
,
dim
=
begin_norm_axis
,
keep_dim
=
True
)
...
...
paddlepalm/task_instance.py
浏览文件 @
fc69141e
...
@@ -113,9 +113,11 @@ class TaskInstance(object):
...
@@ -113,9 +113,11 @@ class TaskInstance(object):
fluid
.
io
.
save_inference_model
(
dirpath
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
,
self
.
_exe
,
prog
)
fluid
.
io
.
save_inference_model
(
dirpath
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
,
self
.
_exe
,
prog
)
conf
=
{}
conf
=
{}
for
k
,
strv
in
self
.
_save_protocol
.
items
():
for
k
,
strv
in
self
.
_save_protocol
.
items
():
exec
(
'v={}'
.
format
(
strv
))
d
=
None
conf
[
k
]
=
v
v
=
locals
()
exec
(
'd={}'
.
format
(
strv
),
globals
(),
v
)
conf
[
k
]
=
v
[
'd'
]
with
open
(
os
.
path
.
join
(
dirpath
,
'__conf__'
),
'w'
)
as
writer
:
with
open
(
os
.
path
.
join
(
dirpath
,
'__conf__'
),
'w'
)
as
writer
:
writer
.
write
(
json
.
dumps
(
conf
,
indent
=
1
))
writer
.
write
(
json
.
dumps
(
conf
,
indent
=
1
))
print
(
self
.
_name
+
': inference model saved at '
+
dirpath
)
print
(
self
.
_name
+
': inference model saved at '
+
dirpath
)
...
@@ -123,7 +125,7 @@ class TaskInstance(object):
...
@@ -123,7 +125,7 @@ class TaskInstance(object):
def
load
(
self
,
infer_model_path
=
None
):
def
load
(
self
,
infer_model_path
=
None
):
if
infer_model_path
is
None
:
if
infer_model_path
is
None
:
infer_model_path
=
self
.
_save_infermodel_path
infer_model_path
=
self
.
_save_infermodel_path
for
k
,
v
in
json
.
load
(
open
(
os
.
path
.
join
(
infer_model_path
,
'__conf__'
))).
items
():
for
k
,
v
in
json
.
load
(
open
(
os
.
path
.
join
(
infer_model_path
,
'__conf__'
))).
items
():
strv
=
self
.
_save_protocol
[
k
]
strv
=
self
.
_save_protocol
[
k
]
exec
(
'{}=v'
.
format
(
strv
))
exec
(
'{}=v'
.
format
(
strv
))
pred_prog
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
=
\
pred_prog
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
=
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录