Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
5f4af11a
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5f4af11a
编写于
9月 07, 2021
作者:
F
Fan Zhang
提交者:
GitHub
9月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CPU-PSLIB] Add consistency insepection of use_var_list and data_generator data (#34988)
上级
0ed9b051
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
471 addition
and
0 deletion
+471
-0
python/paddle/fluid/dataset.py
python/paddle/fluid/dataset.py
+65
-0
python/paddle/fluid/tests/unittests/test_dataset_consistency_inspection.py
...id/tests/unittests/test_dataset_consistency_inspection.py
+406
-0
未找到文件。
python/paddle/fluid/dataset.py
浏览文件 @
5f4af11a
...
@@ -321,6 +321,71 @@ class DatasetBase(object):
...
@@ -321,6 +321,71 @@ class DatasetBase(object):
def
_dynamic_adjust_after_train
(
self
):
def
_dynamic_adjust_after_train
(
self
):
pass
pass
def
check_use_var_with_data_generator
(
self
,
var_list
,
data_generator_class
,
test_file
):
"""
Var consistency insepection of use_var_list and data_generator data.
Examples:
.. code-block:: python
# required: skiptest
import paddle.fluid as fluid
from dataset_generator import CTRDataset
dataset = fluid.DatasetFactory().create_dataset("InMemoryDataset")
generator_class = CTRDataset()
dataset.check_use_var_with_data_generator([data, label], generator_class, "data/part-00000")
Args:
var_list(list): variable list
data_generator_class(class): data_generator class
test_file(str): local test file path
"""
f
=
open
(
test_file
,
"r"
)
var_len
=
len
(
var_list
)
while
True
:
line
=
f
.
readline
()
if
line
:
line_iter
=
data_generator_class
.
generate_sample
(
line
)
for
user_parsed_line
in
line_iter
():
data_gen_len
=
len
(
user_parsed_line
)
if
var_len
!=
data_gen_len
:
raise
ValueError
(
"var length mismatch error: var_list = %s vs data_generator = %s"
%
(
var_len
,
data_gen_len
))
for
i
,
ele
in
enumerate
(
user_parsed_line
):
if
len
(
ele
[
1
])
==
0
:
raise
ValueError
(
"var length error: var %s's length in data_generator is 0"
%
ele
[
0
])
if
var_list
[
i
].
dtype
==
core
.
VarDesc
.
VarType
.
FP32
and
not
all
(
isinstance
(
ele
,
float
)
for
ele
in
ele
[
1
]):
raise
TypeError
(
"var dtype mismatch error: var name = %s, var type in var_list = %s, while var in data_generator contains non-float value, which is %s
\n
"
"Please check if order of var_list and data_generator are aligned.
\n
"
"Please check if var's type in data_generator is correct."
%
(
ele
[
0
],
"float"
,
ele
[
1
]))
if
(
var_list
[
i
].
dtype
==
core
.
VarDesc
.
VarType
.
INT64
or
var_list
[
i
].
dtype
==
core
.
VarDesc
.
VarType
.
INT32
)
and
not
all
(
isinstance
(
ele
,
int
)
for
ele
in
ele
[
1
]):
raise
TypeError
(
"var dtype mismatch error: var name = %s, var type in var_list = %s, while var in data_generator contains non-int value, which is %s
\n
"
"Please check if order of var_list and data_generator are aligned.
\n
"
"Please check if var's type in data_generator is correct."
%
(
ele
[
0
],
"int"
,
ele
[
1
]))
else
:
break
f
.
close
()
class
InMemoryDataset
(
DatasetBase
):
class
InMemoryDataset
(
DatasetBase
):
"""
"""
...
...
python/paddle/fluid/tests/unittests/test_dataset_consistency_inspection.py
0 → 100644
浏览文件 @
5f4af11a
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录