Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
ERNIE
提交
a171e58e
E
ERNIE
项目概览
PaddlePaddle
/
ERNIE
大约 1 年 前同步成功
通知
109
Star
5997
Fork
1270
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
29
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
ERNIE
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
29
Issue
29
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a171e58e
编写于
7月 09, 2019
作者:
P
pkpk
提交者:
GitHub
7月 09, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #194 from tianxin1860/develop
add check_cuda for ERNIE
上级
c0c669ab
cbf2e9d7
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
21 addition
and
4 deletion
+21
-4
BERT/utils/args.py
BERT/utils/args.py
+1
-0
ERNIE/run_classifier.py
ERNIE/run_classifier.py
+2
-2
ERNIE/run_sequence_labeling.py
ERNIE/run_sequence_labeling.py
+2
-1
ERNIE/train.py
ERNIE/train.py
+2
-1
ERNIE/utils/args.py
ERNIE/utils/args.py
+14
-0
未找到文件。
BERT/utils/args.py
浏览文件 @
a171e58e
...
@@ -20,6 +20,7 @@ from __future__ import print_function
...
@@ -20,6 +20,7 @@ from __future__ import print_function
import
six
import
six
import
argparse
import
argparse
import
paddle.fluid
as
fluid
def
str2bool
(
v
):
def
str2bool
(
v
):
# because argparse does not support to parse "true, False" as python
# because argparse does not support to parse "true, False" as python
...
...
ERNIE/run_classifier.py
浏览文件 @
a171e58e
...
@@ -27,7 +27,7 @@ import reader.task_reader as task_reader
...
@@ -27,7 +27,7 @@ import reader.task_reader as task_reader
from
model.ernie
import
ErnieConfig
from
model.ernie
import
ErnieConfig
from
finetune.classifier
import
create_model
,
evaluate
from
finetune.classifier
import
create_model
,
evaluate
from
optimization
import
optimization
from
optimization
import
optimization
from
utils.args
import
print_arguments
from
utils.args
import
print_arguments
,
check_cuda
from
utils.init
import
init_pretraining_params
,
init_checkpoint
from
utils.init
import
init_pretraining_params
,
init_checkpoint
from
finetune_args
import
parser
from
finetune_args
import
parser
...
@@ -272,5 +272,5 @@ def main(args):
...
@@ -272,5 +272,5 @@ def main(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print_arguments
(
args
)
print_arguments
(
args
)
check_cuda
(
args
.
use_cuda
)
main
(
args
)
main
(
args
)
ERNIE/run_sequence_labeling.py
浏览文件 @
a171e58e
...
@@ -27,7 +27,7 @@ import reader.task_reader as task_reader
...
@@ -27,7 +27,7 @@ import reader.task_reader as task_reader
from
model.ernie
import
ErnieConfig
from
model.ernie
import
ErnieConfig
from
optimization
import
optimization
from
optimization
import
optimization
from
utils.init
import
init_pretraining_params
,
init_checkpoint
from
utils.init
import
init_pretraining_params
,
init_checkpoint
from
utils.args
import
print_arguments
from
utils.args
import
print_arguments
,
check_cuda
from
finetune.sequence_label
import
create_model
,
evaluate
from
finetune.sequence_label
import
create_model
,
evaluate
from
finetune_args
import
parser
from
finetune_args
import
parser
...
@@ -280,4 +280,5 @@ def main(args):
...
@@ -280,4 +280,5 @@ def main(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print_arguments
(
args
)
print_arguments
(
args
)
check_cuda
(
args
.
use_cuda
)
main
(
args
)
main
(
args
)
ERNIE/train.py
浏览文件 @
a171e58e
...
@@ -27,7 +27,7 @@ import paddle.fluid as fluid
...
@@ -27,7 +27,7 @@ import paddle.fluid as fluid
from
reader.pretraining
import
ErnieDataReader
from
reader.pretraining
import
ErnieDataReader
from
model.ernie
import
ErnieModel
,
ErnieConfig
from
model.ernie
import
ErnieModel
,
ErnieConfig
from
optimization
import
optimization
from
optimization
import
optimization
from
utils.args
import
print_arguments
from
utils.args
import
print_arguments
,
check_cuda
from
utils.init
import
init_checkpoint
,
init_pretraining_params
from
utils.init
import
init_checkpoint
,
init_pretraining_params
from
pretrain_args
import
parser
from
pretrain_args
import
parser
...
@@ -351,6 +351,7 @@ def train(args):
...
@@ -351,6 +351,7 @@ def train(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print_arguments
(
args
)
print_arguments
(
args
)
check_cuda
(
args
.
use_cuda
)
if
args
.
do_test
:
if
args
.
do_test
:
test
(
args
)
test
(
args
)
else
:
else
:
...
...
ERNIE/utils/args.py
浏览文件 @
a171e58e
...
@@ -20,6 +20,8 @@ from __future__ import print_function
...
@@ -20,6 +20,8 @@ from __future__ import print_function
import
six
import
six
import
argparse
import
argparse
import
paddle.fluid
as
fluid
def
str2bool
(
v
):
def
str2bool
(
v
):
# because argparse does not support to parse "true, False" as python
# because argparse does not support to parse "true, False" as python
...
@@ -46,3 +48,15 @@ def print_arguments(args):
...
@@ -46,3 +48,15 @@ def print_arguments(args):
for
arg
,
value
in
sorted
(
six
.
iteritems
(
vars
(
args
))):
for
arg
,
value
in
sorted
(
six
.
iteritems
(
vars
(
args
))):
print
(
'%s: %s'
%
(
arg
,
value
))
print
(
'%s: %s'
%
(
arg
,
value
))
print
(
'------------------------------------------------'
)
print
(
'------------------------------------------------'
)
def
check_cuda
(
use_cuda
,
err
=
\
"
\n
You can not set use_cuda = True in the model because you are using paddlepaddle-cpu.
\n
\
Please: 1. Install paddlepaddle-gpu to run your models on GPU or 2. Set use_cuda = False to run models on CPU.
\n
"
):
try
:
if
use_cuda
==
True
and
fluid
.
is_compiled_with_cuda
()
==
False
:
print
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
pass
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录