Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
02eacafe
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,发现更多精彩内容 >>
提交
02eacafe
编写于
1月 20, 2020
作者:
X
Xing Wu
提交者:
Guo Sheng
1月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix_lac_windows_int64_error (#4223)
上级
57ac2201
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
5 deletion
+5
-5
dygraph/lac/reader.py
dygraph/lac/reader.py
+5
-5
未找到文件。
dygraph/lac/reader.py
浏览文件 @
02eacafe
...
@@ -21,7 +21,7 @@ import __future__
...
@@ -21,7 +21,7 @@ import __future__
import
io
import
io
import
glob
import
glob
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
numpy
as
np
def
load_kv_dict
(
dict_path
,
def
load_kv_dict
(
dict_path
,
reverse
=
False
,
reverse
=
False
,
...
@@ -56,10 +56,10 @@ class Dataset(object):
...
@@ -56,10 +56,10 @@ class Dataset(object):
def
__init__
(
self
,
args
,
mode
=
"train"
):
def
__init__
(
self
,
args
,
mode
=
"train"
):
# read dict
# read dict
self
.
word2id_dict
=
load_kv_dict
(
self
.
word2id_dict
=
load_kv_dict
(
args
.
word_dict_path
,
reverse
=
True
,
value_func
=
int
)
args
.
word_dict_path
,
reverse
=
True
,
value_func
=
np
.
int64
)
self
.
id2word_dict
=
load_kv_dict
(
args
.
word_dict_path
)
self
.
id2word_dict
=
load_kv_dict
(
args
.
word_dict_path
)
self
.
label2id_dict
=
load_kv_dict
(
self
.
label2id_dict
=
load_kv_dict
(
args
.
label_dict_path
,
reverse
=
True
,
value_func
=
int
)
args
.
label_dict_path
,
reverse
=
True
,
value_func
=
np
.
int64
)
self
.
id2label_dict
=
load_kv_dict
(
args
.
label_dict_path
)
self
.
id2label_dict
=
load_kv_dict
(
args
.
label_dict_path
)
self
.
word_replace_dict
=
load_kv_dict
(
args
.
word_rep_dict_path
)
self
.
word_replace_dict
=
load_kv_dict
(
args
.
word_rep_dict_path
)
...
@@ -150,7 +150,7 @@ class Dataset(object):
...
@@ -150,7 +150,7 @@ class Dataset(object):
new_batch
=
[]
new_batch
=
[]
for
words_len
,
(
word_ids
,
label_ids
)
in
zip
(
init_lens
,
batch
):
for
words_len
,
(
word_ids
,
label_ids
)
in
zip
(
init_lens
,
batch
):
word_ids
=
word_ids
[
0
:
max_seq_len
]
word_ids
=
word_ids
[
0
:
max_seq_len
]
words_len
=
len
(
word_ids
)
words_len
=
np
.
int64
(
len
(
word_ids
)
)
word_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
word_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
label_ids
=
label_ids
[
0
:
max_seq_len
]
label_ids
=
label_ids
[
0
:
max_seq_len
]
label_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
label_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
...
@@ -164,7 +164,7 @@ class Dataset(object):
...
@@ -164,7 +164,7 @@ class Dataset(object):
for
words_len
,
(
word_ids
,
label_ids
)
in
zip
(
init_lens
,
batch
):
for
words_len
,
(
word_ids
,
label_ids
)
in
zip
(
init_lens
,
batch
):
max_seq_len
=
min
(
max
(
init_lens
),
max_seq_len
)
max_seq_len
=
min
(
max
(
init_lens
),
max_seq_len
)
word_ids
=
words
[
0
:
max_seq_len
]
word_ids
=
words
[
0
:
max_seq_len
]
words_len
=
len
(
word_ids
)
words_len
=
np
.
int64
(
len
(
word_ids
)
)
word_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
word_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
label_ids
=
label_ids
[
0
:
max_seq_len
]
label_ids
=
label_ids
[
0
:
max_seq_len
]
label_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
label_ids
+=
[
0
for
_
in
range
(
max_seq_len
-
words_len
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录