Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
7e8ce005
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7e8ce005
编写于
1月 06, 2020
作者:
K
kinghuin
提交者:
wuzewu
1月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix python2 bug (#305)
* fix python2 bug
上级
87257b63
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
16 addition
and
10 deletion
+16
-10
demo/sequence_labeling/predict.py
demo/sequence_labeling/predict.py
+6
-5
paddlehub/finetune/task/base_task.py
paddlehub/finetune/task/base_task.py
+6
-2
paddlehub/finetune/task/reading_comprehension_task.py
paddlehub/finetune/task/reading_comprehension_task.py
+3
-2
paddlehub/reader/tokenization.py
paddlehub/reader/tokenization.py
+1
-1
未找到文件。
demo/sequence_labeling/predict.py
浏览文件 @
7e8ce005
...
@@ -87,12 +87,13 @@ if __name__ == '__main__':
...
@@ -87,12 +87,13 @@ if __name__ == '__main__':
add_crf
=
True
)
add_crf
=
True
)
# Data to be predicted
# Data to be predicted
# If using python 2, prefix "u" is necessary
data
=
[
data
=
[
[
"我们变而以书会友,以书结缘,把欧美、港台流行的食品类图谱、画册、工具书汇集一堂。"
],
[
u
"我们变而以书会友,以书结缘,把欧美、港台流行的食品类图谱、画册、工具书汇集一堂。"
],
[
"为了跟踪国际最新食品工艺、流行趋势,大量搜集海外专业书刊资料是提高技艺的捷径。"
],
[
u
"为了跟踪国际最新食品工艺、流行趋势,大量搜集海外专业书刊资料是提高技艺的捷径。"
],
[
"其中线装古籍逾千册;民国出版物几百种;珍本四册、稀见本四百余册,出版时间跨越三百余年。"
],
[
u
"其中线装古籍逾千册;民国出版物几百种;珍本四册、稀见本四百余册,出版时间跨越三百余年。"
],
[
"有的古木交柯,春机荣欣,从诗人句中得之,而入画中,观之令人心驰。"
],
[
u
"有的古木交柯,春机荣欣,从诗人句中得之,而入画中,观之令人心驰。"
],
[
"不过重在晋趣,略增明人气息,妙在集古有道、不露痕迹罢了。"
],
[
u
"不过重在晋趣,略增明人气息,妙在集古有道、不露痕迹罢了。"
],
]
]
# Add 0x02 between characters to match the format of training data,
# Add 0x02 between characters to match the format of training data,
...
...
paddlehub/finetune/task/base_task.py
浏览文件 @
7e8ce005
...
@@ -24,7 +24,11 @@ import copy
...
@@ -24,7 +24,11 @@ import copy
import
logging
import
logging
import
inspect
import
inspect
from
functools
import
partial
from
functools
import
partial
import
six
if
six
.
PY2
:
from
inspect
import
getargspec
as
get_args
else
:
from
inspect
import
getfullargspec
as
get_args
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
tb_paddle
import
SummaryWriter
from
tb_paddle
import
SummaryWriter
...
@@ -129,7 +133,7 @@ class TaskHooks():
...
@@ -129,7 +133,7 @@ class TaskHooks():
"name: %s has existed in hook_type:%s, use modify method to modify it"
"name: %s has existed in hook_type:%s, use modify method to modify it"
%
(
name
,
hook_type
))
%
(
name
,
hook_type
))
else
:
else
:
args_num
=
len
(
inspect
.
getfullargspec
(
func
).
args
)
args_num
=
len
(
get_args
(
func
).
args
)
if
args_num
!=
self
.
_hook_params_num
[
hook_type
]:
if
args_num
!=
self
.
_hook_params_num
[
hook_type
]:
raise
ValueError
(
raise
ValueError
(
"The number of parameters to the hook hook_type:%s should be %i"
"The number of parameters to the hook hook_type:%s should be %i"
...
...
paddlehub/finetune/task/reading_comprehension_task.py
浏览文件 @
7e8ce005
...
@@ -26,6 +26,7 @@ import json
...
@@ -26,6 +26,7 @@ import json
from
collections
import
OrderedDict
from
collections
import
OrderedDict
import
io
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
.base_task
import
BaseTask
from
.base_task
import
BaseTask
...
@@ -517,13 +518,13 @@ class ReadingComprehensionTask(BaseTask):
...
@@ -517,13 +518,13 @@ class ReadingComprehensionTask(BaseTask):
null_score_diff_threshold
=
self
.
null_score_diff_threshold
,
null_score_diff_threshold
=
self
.
null_score_diff_threshold
,
is_english
=
self
.
is_english
)
is_english
=
self
.
is_english
)
if
self
.
phase
==
'val'
or
self
.
phase
==
'dev'
:
if
self
.
phase
==
'val'
or
self
.
phase
==
'dev'
:
with
open
(
with
io
.
open
(
self
.
data_reader
.
dataset
.
dev_path
,
'r'
,
self
.
data_reader
.
dataset
.
dev_path
,
'r'
,
encoding
=
"utf8"
)
as
dataset_file
:
encoding
=
"utf8"
)
as
dataset_file
:
dataset_json
=
json
.
load
(
dataset_file
)
dataset_json
=
json
.
load
(
dataset_file
)
dataset
=
dataset_json
[
'data'
]
dataset
=
dataset_json
[
'data'
]
elif
self
.
phase
==
'test'
:
elif
self
.
phase
==
'test'
:
with
open
(
with
io
.
open
(
self
.
data_reader
.
dataset
.
test_path
,
'r'
,
self
.
data_reader
.
dataset
.
test_path
,
'r'
,
encoding
=
"utf8"
)
as
dataset_file
:
encoding
=
"utf8"
)
as
dataset_file
:
dataset_json
=
json
.
load
(
dataset_file
)
dataset_json
=
json
.
load
(
dataset_file
)
...
...
paddlehub/reader/tokenization.py
浏览文件 @
7e8ce005
...
@@ -170,7 +170,7 @@ class WSSPTokenizer(object):
...
@@ -170,7 +170,7 @@ class WSSPTokenizer(object):
self
.
inv_vocab
=
{
v
:
k
for
k
,
v
in
self
.
vocab
.
items
()}
self
.
inv_vocab
=
{
v
:
k
for
k
,
v
in
self
.
vocab
.
items
()}
self
.
ws
=
ws
self
.
ws
=
ws
self
.
lower
=
lower
self
.
lower
=
lower
self
.
dict
=
pickle
.
load
(
open
(
word_dict
,
'rb'
)
,
encoding
=
'utf8'
)
self
.
dict
=
pickle
.
load
(
open
(
word_dict
,
'rb'
))
self
.
sp_model
=
spm
.
SentencePieceProcessor
()
self
.
sp_model
=
spm
.
SentencePieceProcessor
()
self
.
window_size
=
5
self
.
window_size
=
5
self
.
sp_model
.
Load
(
sp_model_dir
)
self
.
sp_model
.
Load
(
sp_model_dir
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录