Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sjm155647132
ERNIE
提交
dac6d74e
E
ERNIE
项目概览
sjm155647132
/
ERNIE
与 Fork 源项目一致
Fork自
PaddlePaddle / ERNIE
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
ERNIE
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dac6d74e
编写于
7月 18, 2019
作者:
T
tianxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add utils/init.py
test=develop fix #215
上级
c555bff4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
11 deletion
+78
-11
ELMo/train.py
ELMo/train.py
+11
-11
ELMo/utils/init.py
ELMo/utils/init.py
+67
-0
未找到文件。
ELMo/train.py
浏览文件 @
dac6d74e
...
...
@@ -17,24 +17,27 @@ from __future__ import division
from
__future__
import
print_function
import
six
import
numpy
as
np
import
os
import
random
import
time
import
os
import
math
import
pickle
import
logging
import
numpy
as
np
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
import
paddle.fluid.framework
as
framework
from
paddle.fluid.executor
import
Executor
import
data
from
args
import
*
from
utils.cards
import
get_cards
import
lm_model
import
logging
from
args
import
parse_args
from
utils.cards
import
get_cards
from
utils.init
import
init_pretraining_params
logging
.
basicConfig
()
import
pickle
def
prepare_batch_input
(
batch
,
args
):
...
...
@@ -576,11 +579,8 @@ def train_loop(args,
ce_time
=
ce_info
[
-
2
][
1
]
except
:
print
(
"ce info error"
)
print
(
"kpis
\t
train_duration_card%s
\t
%s"
%
(
card_num
,
ce_time
))
print
(
"kpis
\t
train_loss_card%s
\t
%f"
%
(
card_num
,
ce_loss
))
print
(
"kpis
\t
train_duration_card%s
\t
%s"
%
(
card_num
,
ce_time
))
print
(
"kpis
\t
train_loss_card%s
\t
%f"
%
(
card_num
,
ce_loss
))
end_time
=
time
.
time
()
total_time
+=
end_time
-
start_time
...
...
ELMo/utils/init.py
0 → 100644
浏览文件 @
dac6d74e
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
print_function
import
os
import
six
import
ast
import
copy
import
numpy
as
np
import
paddle.fluid
as
fluid
def
init_checkpoint
(
exe
,
init_checkpoint_path
,
main_program
,
use_fp16
=
False
):
assert
os
.
path
.
exists
(
init_checkpoint_path
),
"[%s] cann't be found."
%
init_checkpoint_path
def
existed_persitables
(
var
):
if
not
fluid
.
io
.
is_persistable
(
var
):
return
False
return
os
.
path
.
exists
(
os
.
path
.
join
(
init_checkpoint_path
,
var
.
name
))
fluid
.
io
.
load_vars
(
exe
,
init_checkpoint_path
,
main_program
=
main_program
,
predicate
=
existed_persitables
)
print
(
"Load model from {}"
.
format
(
init_checkpoint_path
))
if
use_fp16
:
cast_fp32_to_fp16
(
exe
,
main_program
)
def
init_pretraining_params
(
exe
,
pretraining_params_path
,
main_program
,
use_fp16
=
False
):
assert
os
.
path
.
exists
(
pretraining_params_path
),
"[%s] cann't be found."
%
pretraining_params_path
def
existed_params
(
var
):
if
not
isinstance
(
var
,
fluid
.
framework
.
Parameter
):
return
False
return
os
.
path
.
exists
(
os
.
path
.
join
(
pretraining_params_path
,
var
.
name
))
fluid
.
io
.
load_vars
(
exe
,
pretraining_params_path
,
main_program
=
main_program
,
predicate
=
existed_params
)
print
(
"Load pretraining parameters from {}."
.
format
(
pretraining_params_path
))
if
use_fp16
:
cast_fp32_to_fp16
(
exe
,
main_program
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录