Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
c07a8d20
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c07a8d20
编写于
7月 17, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
7月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
!3137 Cleanup dataset UT: Remove deprecated save_and_check
Merge pull request !3137 from cathwong/ckw_dataset_ut_cleanup7
上级
863f4e4f
04eb4f89
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
117 addition
and
224 deletion
+117
-224
tests/ut/data/dataset/golden/batch_01_result.npz
tests/ut/data/dataset/golden/batch_01_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_02_result.npz
tests/ut/data/dataset/golden/batch_02_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_03_result.npz
tests/ut/data/dataset/golden/batch_03_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_04_result.npz
tests/ut/data/dataset/golden/batch_04_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_05_result.npz
tests/ut/data/dataset/golden/batch_05_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_06_result.npz
tests/ut/data/dataset/golden/batch_06_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_07_result.npz
tests/ut/data/dataset/golden/batch_07_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_08_result.npz
tests/ut/data/dataset/golden/batch_08_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_09_result.npz
tests/ut/data/dataset/golden/batch_09_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_10_result.npz
tests/ut/data/dataset/golden/batch_10_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_11_result.npz
tests/ut/data/dataset/golden/batch_11_result.npz
+0
-0
tests/ut/data/dataset/golden/batch_12_result.npz
tests/ut/data/dataset/golden/batch_12_result.npz
+0
-0
tests/ut/data/dataset/golden/shuffle_01_result.npz
tests/ut/data/dataset/golden/shuffle_01_result.npz
+0
-0
tests/ut/data/dataset/golden/shuffle_02_result.npz
tests/ut/data/dataset/golden/shuffle_02_result.npz
+0
-0
tests/ut/data/dataset/golden/shuffle_03_result.npz
tests/ut/data/dataset/golden/shuffle_03_result.npz
+0
-0
tests/ut/data/dataset/golden/shuffle_04_result.npz
tests/ut/data/dataset/golden/shuffle_04_result.npz
+0
-0
tests/ut/data/dataset/golden/shuffle_05_result.npz
tests/ut/data/dataset/golden/shuffle_05_result.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_batch_repeat.npz
tests/ut/data/dataset/golden/test_2ops_batch_repeat.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_batch_shuffle.npz
tests/ut/data/dataset/golden/test_2ops_batch_shuffle.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_repeat_batch.npz
tests/ut/data/dataset/golden/test_2ops_repeat_batch.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_repeat_shuffle.npz
tests/ut/data/dataset/golden/test_2ops_repeat_shuffle.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_shuffle_batch.npz
tests/ut/data/dataset/golden/test_2ops_shuffle_batch.npz
+0
-0
tests/ut/data/dataset/golden/test_2ops_shuffle_repeat.npz
tests/ut/data/dataset/golden/test_2ops_shuffle_repeat.npz
+0
-0
tests/ut/data/dataset/testImageNetData2/dataDistributionAll.json
...t/data/dataset/testImageNetData2/dataDistributionAll.json
+0
-8
tests/ut/data/dataset/testImageNetData2/dataDistributionRandom.json
...ata/dataset/testImageNetData2/dataDistributionRandom.json
+0
-8
tests/ut/data/dataset/testImageNetData2/dataDistributionUnique.json
...ata/dataset/testImageNetData2/dataDistributionUnique.json
+0
-8
tests/ut/data/dataset/testPK/distribution.json
tests/ut/data/dataset/testPK/distribution.json
+0
-7
tests/ut/python/dataset/test_2ops.py
tests/ut/python/dataset/test_2ops.py
+7
-27
tests/ut/python/dataset/test_batch.py
tests/ut/python/dataset/test_batch.py
+13
-35
tests/ut/python/dataset/test_datasets_clue.py
tests/ut/python/dataset/test_datasets_clue.py
+4
-0
tests/ut/python/dataset/test_datasets_generator.py
tests/ut/python/dataset/test_datasets_generator.py
+58
-58
tests/ut/python/dataset/test_datasets_tfrecord.py
tests/ut/python/dataset/test_datasets_tfrecord.py
+0
-0
tests/ut/python/dataset/test_iterator.py
tests/ut/python/dataset/test_iterator.py
+6
-2
tests/ut/python/dataset/test_shuffle.py
tests/ut/python/dataset/test_shuffle.py
+6
-12
tests/ut/python/dataset/util.py
tests/ut/python/dataset/util.py
+23
-59
未找到文件。
tests/ut/data/dataset/golden/batch_01_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_02_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_03_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_04_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_05_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_06_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_07_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_08_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_09_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_10_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_11_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/batch_12_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/shuffle_01_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/shuffle_02_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/shuffle_03_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/shuffle_04_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/shuffle_05_result.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_batch_repeat.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_batch_shuffle.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_repeat_batch.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_repeat_shuffle.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_shuffle_batch.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/golden/test_2ops_shuffle_repeat.npz
浏览文件 @
c07a8d20
无法预览此类型文件
tests/ut/data/dataset/testImageNetData2/dataDistributionAll.json
已删除
100644 → 0
浏览文件 @
863f4e4f
{
"deviceNum"
:
4
,
"deviceId"
:
2
,
"shardConfig"
:
"ALL"
,
"shuffle"
:
"ON"
,
"seed"
:
0
,
"epoch"
:
2
}
tests/ut/data/dataset/testImageNetData2/dataDistributionRandom.json
已删除
100644 → 0
浏览文件 @
863f4e4f
{
"deviceNum"
:
4
,
"deviceId"
:
2
,
"shardConfig"
:
"RANDOM"
,
"shuffle"
:
"ON"
,
"seed"
:
0
,
"epoch"
:
1
}
tests/ut/data/dataset/testImageNetData2/dataDistributionUnique.json
已删除
100644 → 0
浏览文件 @
863f4e4f
{
"deviceNum"
:
4
,
"deviceId"
:
2
,
"shardConfig"
:
"UNIQUE"
,
"shuffle"
:
"ON"
,
"seed"
:
0
,
"epoch"
:
3
}
tests/ut/data/dataset/testPK/distribution.json
已删除
100644 → 0
浏览文件 @
863f4e4f
{
"deviceNum"
:
1
,
"deviceId"
:
0
,
"shardConfig"
:
"RANDOM"
,
"shuffle"
:
"OFF"
,
"seed"
:
0
}
tests/ut/python/dataset/test_2ops.py
浏览文件 @
c07a8d20
...
...
@@ -12,15 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
from
util
import
save_and_check
import
mindspore.dataset
as
ds
from
mindspore
import
log
as
logger
from
util
import
save_and_check_dict
DATA_DIR
=
[
"../data/dataset/testTFTestAllTypes/test.data"
]
SCHEMA_DIR
=
"../data/dataset/testTFTestAllTypes/datasetSchema.json"
COLUMNS
=
[
"col_1d"
,
"col_2d"
,
"col_3d"
,
"col_binary"
,
"col_float"
,
"col_sint16"
,
"col_sint32"
,
"col_sint64"
]
GENERATE_GOLDEN
=
False
...
...
@@ -33,9 +30,6 @@ def test_2ops_repeat_shuffle():
repeat_count
=
2
buffer_size
=
5
seed
=
0
parameters
=
{
"params"
:
{
'repeat_count'
:
repeat_count
,
'buffer_size'
:
buffer_size
,
'seed'
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -44,7 +38,7 @@ def test_2ops_repeat_shuffle():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"test_2ops_repeat_shuffle.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_2ops_shuffle_repeat
():
...
...
@@ -56,10 +50,6 @@ def test_2ops_shuffle_repeat():
repeat_count
=
2
buffer_size
=
5
seed
=
0
parameters
=
{
"params"
:
{
'repeat_count'
:
repeat_count
,
'buffer_size'
:
buffer_size
,
'reshuffle_each_iteration'
:
False
,
'seed'
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -68,7 +58,7 @@ def test_2ops_shuffle_repeat():
data1
=
data1
.
repeat
(
repeat_count
)
filename
=
"test_2ops_shuffle_repeat.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_2ops_repeat_batch
():
...
...
@@ -79,8 +69,6 @@ def test_2ops_repeat_batch():
# define parameters
repeat_count
=
2
batch_size
=
5
parameters
=
{
"params"
:
{
'repeat_count'
:
repeat_count
,
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -88,7 +76,7 @@ def test_2ops_repeat_batch():
data1
=
data1
.
batch
(
batch_size
,
drop_remainder
=
True
)
filename
=
"test_2ops_repeat_batch.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_2ops_batch_repeat
():
...
...
@@ -99,8 +87,6 @@ def test_2ops_batch_repeat():
# define parameters
repeat_count
=
2
batch_size
=
5
parameters
=
{
"params"
:
{
'repeat_count'
:
repeat_count
,
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -108,7 +94,7 @@ def test_2ops_batch_repeat():
data1
=
data1
.
repeat
(
repeat_count
)
filename
=
"test_2ops_batch_repeat.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_2ops_batch_shuffle
():
...
...
@@ -120,9 +106,6 @@ def test_2ops_batch_shuffle():
buffer_size
=
5
seed
=
0
batch_size
=
2
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
'seed'
:
seed
,
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -131,7 +114,7 @@ def test_2ops_batch_shuffle():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"test_2ops_batch_shuffle.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_2ops_shuffle_batch
():
...
...
@@ -143,9 +126,6 @@ def test_2ops_shuffle_batch():
buffer_size
=
5
seed
=
0
batch_size
=
2
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
'seed'
:
seed
,
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
shuffle
=
False
)
...
...
@@ -154,7 +134,7 @@ def test_2ops_shuffle_batch():
data1
=
data1
.
batch
(
batch_size
,
drop_remainder
=
True
)
filename
=
"test_2ops_shuffle_batch.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
if
__name__
==
'__main__'
:
...
...
tests/ut/python/dataset/test_batch.py
浏览文件 @
c07a8d20
...
...
@@ -14,7 +14,7 @@
# ==============================================================================
import
mindspore.dataset
as
ds
from
mindspore
import
log
as
logger
from
util
import
save_and_check
from
util
import
save_and_check
_dict
# Note: Number of rows in test.data dataset: 12
DATA_DIR
=
[
"../data/dataset/testTFTestAllTypes/test.data"
]
...
...
@@ -29,8 +29,6 @@ def test_batch_01():
# define parameters
batch_size
=
2
drop_remainder
=
True
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -38,7 +36,7 @@ def test_batch_01():
assert
sum
([
1
for
_
in
data1
])
==
6
filename
=
"batch_01_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_02
():
...
...
@@ -49,8 +47,6 @@ def test_batch_02():
# define parameters
batch_size
=
5
drop_remainder
=
True
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -58,7 +54,7 @@ def test_batch_02():
assert
sum
([
1
for
_
in
data1
])
==
2
filename
=
"batch_02_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_03
():
...
...
@@ -69,8 +65,6 @@ def test_batch_03():
# define parameters
batch_size
=
3
drop_remainder
=
False
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -78,7 +72,7 @@ def test_batch_03():
assert
sum
([
1
for
_
in
data1
])
==
4
filename
=
"batch_03_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_04
():
...
...
@@ -89,8 +83,6 @@ def test_batch_04():
# define parameters
batch_size
=
7
drop_remainder
=
False
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -98,7 +90,7 @@ def test_batch_04():
assert
sum
([
1
for
_
in
data1
])
==
2
filename
=
"batch_04_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_05
():
...
...
@@ -108,7 +100,6 @@ def test_batch_05():
logger
.
info
(
"test_batch_05"
)
# define parameters
batch_size
=
1
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -116,7 +107,7 @@ def test_batch_05():
assert
sum
([
1
for
_
in
data1
])
==
12
filename
=
"batch_05_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_06
():
...
...
@@ -127,8 +118,6 @@ def test_batch_06():
# define parameters
batch_size
=
12
drop_remainder
=
False
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -136,7 +125,7 @@ def test_batch_06():
assert
sum
([
1
for
_
in
data1
])
==
1
filename
=
"batch_06_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_07
():
...
...
@@ -148,9 +137,6 @@ def test_batch_07():
batch_size
=
4
drop_remainder
=
False
num_parallel_workers
=
2
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
,
'num_parallel_workers'
:
num_parallel_workers
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -159,7 +145,7 @@ def test_batch_07():
assert
sum
([
1
for
_
in
data1
])
==
3
filename
=
"batch_07_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_08
():
...
...
@@ -170,8 +156,6 @@ def test_batch_08():
# define parameters
batch_size
=
6
num_parallel_workers
=
1
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'num_parallel_workers'
:
num_parallel_workers
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -179,7 +163,7 @@ def test_batch_08():
assert
sum
([
1
for
_
in
data1
])
==
2
filename
=
"batch_08_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_09
():
...
...
@@ -190,8 +174,6 @@ def test_batch_09():
# define parameters
batch_size
=
13
drop_remainder
=
False
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -199,7 +181,7 @@ def test_batch_09():
assert
sum
([
1
for
_
in
data1
])
==
1
filename
=
"batch_09_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_10
():
...
...
@@ -210,8 +192,6 @@ def test_batch_10():
# define parameters
batch_size
=
99
drop_remainder
=
True
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
,
'drop_remainder'
:
drop_remainder
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -219,7 +199,7 @@ def test_batch_10():
assert
sum
([
1
for
_
in
data1
])
==
0
filename
=
"batch_10_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_11
():
...
...
@@ -229,7 +209,6 @@ def test_batch_11():
logger
.
info
(
"test_batch_11"
)
# define parameters
batch_size
=
1
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
}}
# apply dataset operations
# Use schema file with 1 row
...
...
@@ -239,7 +218,7 @@ def test_batch_11():
assert
sum
([
1
for
_
in
data1
])
==
1
filename
=
"batch_11_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_12
():
...
...
@@ -249,7 +228,6 @@ def test_batch_12():
logger
.
info
(
"test_batch_12"
)
# define parameters
batch_size
=
True
parameters
=
{
"params"
:
{
'batch_size'
:
batch_size
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -257,7 +235,7 @@ def test_batch_12():
assert
sum
([
1
for
_
in
data1
])
==
12
filename
=
"batch_12_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_batch_exception_01
():
...
...
tests/ut/python/dataset/test_datasets_clue.py
浏览文件 @
c07a8d20
...
...
@@ -356,9 +356,13 @@ def test_clue_to_device():
if
__name__
==
"__main__"
:
test_clue
()
test_clue_num_shards
()
test_clue_num_samples
()
test_textline_dataset_get_datasetsize
()
test_clue_afqmc
()
test_clue_cmnli
()
test_clue_csl
()
test_clue_iflytek
()
test_clue_tnews
()
test_clue_wsc
()
test_clue_to_device
()
tests/ut/python/dataset/test_generator.py
→
tests/ut/python/dataset/test_
datasets_
generator.py
浏览文件 @
c07a8d20
...
...
@@ -26,7 +26,7 @@ def generator_1d():
yield
(
np
.
array
([
i
]),)
def
test_
case
_0
():
def
test_
generator
_0
():
"""
Test 1D Generator
"""
...
...
@@ -48,7 +48,7 @@ def generator_md():
yield
(
np
.
array
([[
i
,
i
+
1
],
[
i
+
2
,
i
+
3
]]),)
def
test_
case
_1
():
def
test_
generator
_1
():
"""
Test MD Generator
"""
...
...
@@ -70,7 +70,7 @@ def generator_mc(maxid=64):
yield
(
np
.
array
([
i
]),
np
.
array
([[
i
,
i
+
1
],
[
i
+
2
,
i
+
3
]]))
def
test_
case
_2
():
def
test_
generator
_2
():
"""
Test multi column generator
"""
...
...
@@ -88,7 +88,7 @@ def test_case_2():
i
=
i
+
1
def
test_
case
_3
():
def
test_
generator
_3
():
"""
Test 1D Generator + repeat(4)
"""
...
...
@@ -108,7 +108,7 @@ def test_case_3():
i
=
0
def
test_
case
_4
():
def
test_
generator
_4
():
"""
Test fixed size 1D Generator + batch
"""
...
...
@@ -146,7 +146,7 @@ def type_tester(t):
i
=
i
+
4
def
test_
case
_5
():
def
test_
generator
_5
():
"""
Test 1D Generator on different data type
"""
...
...
@@ -173,7 +173,7 @@ def type_tester_with_type_check(t, c):
i
=
i
+
4
def
test_
case
_6
():
def
test_
generator
_6
():
"""
Test 1D Generator on different data type with type check
"""
...
...
@@ -208,7 +208,7 @@ def type_tester_with_type_check_2c(t, c):
i
=
i
+
4
def
test_
case
_7
():
def
test_
generator
_7
():
"""
Test 2 column Generator on different data type with type check
"""
...
...
@@ -223,7 +223,7 @@ def test_case_7():
type_tester_with_type_check_2c
(
np_types
[
i
],
[
None
,
de_types
[
i
]])
def
test_
case
_8
():
def
test_
generator
_8
():
"""
Test multi column generator with few mapops
"""
...
...
@@ -249,7 +249,7 @@ def test_case_8():
i
=
i
+
1
def
test_
case
_9
():
def
test_
generator
_9
():
"""
Test map column order when len(input_columns) == len(output_columns).
"""
...
...
@@ -280,7 +280,7 @@ def test_case_9():
i
=
i
+
1
def
test_
case
_10
():
def
test_
generator
_10
():
"""
Test map column order when len(input_columns) != len(output_columns).
"""
...
...
@@ -303,7 +303,7 @@ def test_case_10():
i
=
i
+
1
def
test_
case
_11
():
def
test_
generator
_11
():
"""
Test map column order when len(input_columns) != len(output_columns).
"""
...
...
@@ -327,7 +327,7 @@ def test_case_11():
i
=
i
+
1
def
test_
case
_12
():
def
test_
generator
_12
():
"""
Test map column order when input_columns and output_columns are None.
"""
...
...
@@ -361,7 +361,7 @@ def test_case_12():
i
=
i
+
1
def
test_
case
_13
():
def
test_
generator
_13
():
"""
Test map column order when input_columns is None.
"""
...
...
@@ -391,7 +391,7 @@ def test_case_13():
i
=
i
+
1
def
test_
case
_14
():
def
test_
generator
_14
():
"""
Test 1D Generator MP + CPP sampler
"""
...
...
@@ -408,7 +408,7 @@ def test_case_14():
i
=
0
def
test_
case
_15
():
def
test_
generator
_15
():
"""
Test 1D Generator MP + Python sampler
"""
...
...
@@ -426,7 +426,7 @@ def test_case_15():
i
=
0
def
test_
case
_16
():
def
test_
generator
_16
():
"""
Test multi column generator Mp + CPP sampler
"""
...
...
@@ -445,7 +445,7 @@ def test_case_16():
i
=
i
+
1
def
test_
case
_17
():
def
test_
generator
_17
():
"""
Test multi column generator Mp + Python sampler
"""
...
...
@@ -465,7 +465,7 @@ def test_case_17():
i
=
i
+
1
def
test_
case
_error_1
():
def
test_
generator
_error_1
():
def
generator_np
():
for
i
in
range
(
64
):
yield
(
np
.
array
([{
i
}]),)
...
...
@@ -477,7 +477,7 @@ def test_case_error_1():
assert
"Invalid data type"
in
str
(
info
.
value
)
def
test_
case
_error_2
():
def
test_
generator
_error_2
():
def
generator_np
():
for
i
in
range
(
64
):
yield
({
i
},)
...
...
@@ -489,7 +489,7 @@ def test_case_error_2():
assert
"Generator should return a tuple of numpy arrays"
in
str
(
info
.
value
)
def
test_
case
_error_3
():
def
test_
generator
_error_3
():
with
pytest
.
raises
(
ValueError
)
as
info
:
# apply dataset operations
data1
=
ds
.
GeneratorDataset
(
generator_mc
(
2048
),
[
"label"
,
"image"
])
...
...
@@ -501,7 +501,7 @@ def test_case_error_3():
assert
"When (len(input_columns) != len(output_columns)), columns_order must be specified."
in
str
(
info
.
value
)
def
test_
case
_error_4
():
def
test_
generator
_error_4
():
with
pytest
.
raises
(
RuntimeError
)
as
info
:
# apply dataset operations
data1
=
ds
.
GeneratorDataset
(
generator_mc
(
2048
),
[
"label"
,
"image"
])
...
...
@@ -513,7 +513,7 @@ def test_case_error_4():
assert
"Unexpected error. Result of a tensorOp doesn't match output column names"
in
str
(
info
.
value
)
def
test_sequential_sampler
():
def
test_
generator_
sequential_sampler
():
source
=
[(
np
.
array
([
x
]),)
for
x
in
range
(
64
)]
ds1
=
ds
.
GeneratorDataset
(
source
,
[
"data"
],
sampler
=
ds
.
SequentialSampler
())
i
=
0
...
...
@@ -523,14 +523,14 @@ def test_sequential_sampler():
i
=
i
+
1
def
test_random_sampler
():
def
test_
generator_
random_sampler
():
source
=
[(
np
.
array
([
x
]),)
for
x
in
range
(
64
)]
ds1
=
ds
.
GeneratorDataset
(
source
,
[
"data"
],
shuffle
=
True
)
for
_
in
ds1
.
create_dict_iterator
():
# each data is a dictionary
pass
def
test_distributed_sampler
():
def
test_
generator_
distributed_sampler
():
source
=
[(
np
.
array
([
x
]),)
for
x
in
range
(
64
)]
for
sid
in
range
(
8
):
ds1
=
ds
.
GeneratorDataset
(
source
,
[
"data"
],
shuffle
=
False
,
num_shards
=
8
,
shard_id
=
sid
)
...
...
@@ -541,7 +541,7 @@ def test_distributed_sampler():
i
=
i
+
8
def
test_num_samples
():
def
test_
generator_
num_samples
():
source
=
[(
np
.
array
([
x
]),)
for
x
in
range
(
64
)]
num_samples
=
32
ds1
=
ds
.
GeneratorDataset
(
source
,
[
"data"
],
sampler
=
ds
.
SequentialSampler
(
num_samples
=
num_samples
))
...
...
@@ -564,7 +564,7 @@ def test_num_samples():
assert
count
==
num_samples
def
test_num_samples_underflow
():
def
test_
generator_
num_samples_underflow
():
source
=
[(
np
.
array
([
x
]),)
for
x
in
range
(
64
)]
num_samples
=
256
ds2
=
ds
.
GeneratorDataset
(
source
,
[
"data"
],
sampler
=
[
i
for
i
in
range
(
64
)],
num_samples
=
num_samples
)
...
...
@@ -600,7 +600,7 @@ def type_tester_with_type_check_2c_schema(t, c):
i
=
i
+
4
def
test_schema
():
def
test_
generator_
schema
():
"""
Test 2 column Generator on different data type with type check with schema input
"""
...
...
@@ -615,9 +615,9 @@ def test_schema():
type_tester_with_type_check_2c_schema
(
np_types
[
i
],
[
de_types
[
i
],
de_types
[
i
]])
def
manual_test_
keybora
d_interrupt
():
def
manual_test_
generator_keyboar
d_interrupt
():
"""
Test keybo
ra
d_interrupt
Test keybo
ar
d_interrupt
"""
logger
.
info
(
"Test 1D Generator MP : 0 - 63"
)
...
...
@@ -635,31 +635,31 @@ def manual_test_keyborad_interrupt():
if
__name__
==
"__main__"
:
test_
case
_0
()
test_
case
_1
()
test_
case
_2
()
test_
case
_3
()
test_
case
_4
()
test_
case
_5
()
test_
case
_6
()
test_
case
_7
()
test_
case
_8
()
test_
case
_9
()
test_
case
_10
()
test_
case
_11
()
test_
case
_12
()
test_
case
_13
()
test_
case
_14
()
test_
case
_15
()
test_
case
_16
()
test_
case
_17
()
test_
case
_error_1
()
test_
case
_error_2
()
test_
case
_error_3
()
test_
case
_error_4
()
test_sequential_sampler
()
test_distributed_sampler
()
test_random_sampler
()
test_num_samples
()
test_num_samples_underflow
()
test_schema
()
test_
generator
_0
()
test_
generator
_1
()
test_
generator
_2
()
test_
generator
_3
()
test_
generator
_4
()
test_
generator
_5
()
test_
generator
_6
()
test_
generator
_7
()
test_
generator
_8
()
test_
generator
_9
()
test_
generator
_10
()
test_
generator
_11
()
test_
generator
_12
()
test_
generator
_13
()
test_
generator
_14
()
test_
generator
_15
()
test_
generator
_16
()
test_
generator
_17
()
test_
generator
_error_1
()
test_
generator
_error_2
()
test_
generator
_error_3
()
test_
generator
_error_4
()
test_
generator_
sequential_sampler
()
test_
generator_
distributed_sampler
()
test_
generator_
random_sampler
()
test_
generator_
num_samples
()
test_
generator_
num_samples_underflow
()
test_
generator_
schema
()
tests/ut/python/dataset/test_
tfreader_op
.py
→
tests/ut/python/dataset/test_
datasets_tfrecord
.py
浏览文件 @
c07a8d20
文件已移动
tests/ut/python/dataset/test_iterator.py
浏览文件 @
c07a8d20
...
...
@@ -33,7 +33,7 @@ def check(project_columns):
assert
all
([
np
.
array_equal
(
d1
,
d2
)
for
d1
,
d2
in
zip
(
data_actual
,
data_expected
)])
def
test_
case_iterator
():
def
test_
iterator_create_tuple
():
"""
Test creating tuple iterator
"""
...
...
@@ -95,7 +95,9 @@ class MyDict(dict):
def
test_tree_copy
():
# Testing copying the tree with a pyfunc that cannot be pickled
"""
Testing copying the tree with a pyfunc that cannot be pickled
"""
data
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
columns_list
=
COLUMNS
)
data1
=
data
.
map
(
operations
=
[
MyDict
()])
...
...
@@ -110,4 +112,6 @@ def test_tree_copy():
if
__name__
==
'__main__'
:
test_iterator_create_tuple
()
test_iterator_weak_ref
()
test_tree_copy
()
tests/ut/python/dataset/test_shuffle.py
浏览文件 @
c07a8d20
...
...
@@ -13,10 +13,9 @@
# limitations under the License.
# ==============================================================================
import
numpy
as
np
from
util
import
save_and_check
import
mindspore.dataset
as
ds
from
mindspore
import
log
as
logger
from
util
import
save_and_check_dict
# Note: Number of rows in test.data dataset: 12
DATA_DIR
=
[
"../data/dataset/testTFTestAllTypes/test.data"
]
...
...
@@ -31,7 +30,6 @@ def test_shuffle_01():
# define parameters
buffer_size
=
5
seed
=
1
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
"seed"
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -39,7 +37,7 @@ def test_shuffle_01():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"shuffle_01_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_shuffle_02
():
...
...
@@ -50,7 +48,6 @@ def test_shuffle_02():
# define parameters
buffer_size
=
12
seed
=
1
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
"seed"
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -58,7 +55,7 @@ def test_shuffle_02():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"shuffle_02_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_shuffle_03
():
...
...
@@ -69,7 +66,6 @@ def test_shuffle_03():
# define parameters
buffer_size
=
2
seed
=
1
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
"seed"
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -77,7 +73,7 @@ def test_shuffle_03():
data1
=
data1
.
shuffle
(
buffer_size
)
filename
=
"shuffle_03_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_shuffle_04
():
...
...
@@ -88,7 +84,6 @@ def test_shuffle_04():
# define parameters
buffer_size
=
2
seed
=
1
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
"seed"
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
num_samples
=
2
)
...
...
@@ -96,7 +91,7 @@ def test_shuffle_04():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"shuffle_04_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_shuffle_05
():
...
...
@@ -107,7 +102,6 @@ def test_shuffle_05():
# define parameters
buffer_size
=
13
seed
=
1
parameters
=
{
"params"
:
{
'buffer_size'
:
buffer_size
,
"seed"
:
seed
}}
# apply dataset operations
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
shuffle
=
ds
.
Shuffle
.
FILES
)
...
...
@@ -115,7 +109,7 @@ def test_shuffle_05():
data1
=
data1
.
shuffle
(
buffer_size
=
buffer_size
)
filename
=
"shuffle_05_result.npz"
save_and_check
(
data1
,
parameters
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
save_and_check
_dict
(
data1
,
filename
,
generate_golden
=
GENERATE_GOLDEN
)
def
test_shuffle_06
():
...
...
tests/ut/python/dataset/util.py
浏览文件 @
c07a8d20
...
...
@@ -24,9 +24,6 @@ import numpy as np
import
mindspore.dataset
as
ds
from
mindspore
import
log
as
logger
# These are the column names defined in the testTFTestAllTypes dataset
COLUMNS
=
[
"col_1d"
,
"col_2d"
,
"col_3d"
,
"col_binary"
,
"col_float"
,
"col_sint16"
,
"col_sint32"
,
"col_sint64"
]
# These are list of plot title in different visualize modes
PLOT_TITLE_DICT
=
{
1
:
[
"Original image"
,
"Transformed image"
],
...
...
@@ -82,39 +79,6 @@ def _save_json(filename, parameters, result_dict):
fout
.
write
(
jsbeautifier
.
beautify
(
json
.
dumps
(
out_dict
),
options
))
def
save_and_check
(
data
,
parameters
,
filename
,
generate_golden
=
False
):
"""
Save the dataset dictionary and compare (as numpy array) with golden file.
Use create_dict_iterator to access the dataset.
Note: save_and_check() is deprecated; use save_and_check_dict().
"""
num_iter
=
0
result_dict
=
{}
for
column_name
in
COLUMNS
:
result_dict
[
column_name
]
=
[]
for
item
in
data
.
create_dict_iterator
():
# each data is a dictionary
for
data_key
in
list
(
item
.
keys
()):
if
data_key
not
in
result_dict
:
result_dict
[
data_key
]
=
[]
result_dict
[
data_key
].
append
(
item
[
data_key
].
tolist
())
num_iter
+=
1
logger
.
info
(
"Number of data in data1: {}"
.
format
(
num_iter
))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
golden_ref_dir
=
os
.
path
.
join
(
cur_dir
,
"../../data/dataset"
,
'golden'
,
filename
)
if
generate_golden
:
# Save as the golden result
_save_golden
(
cur_dir
,
golden_ref_dir
,
result_dict
)
_compare_to_golden
(
golden_ref_dir
,
result_dict
)
if
SAVE_JSON
:
# Save result to a json file for inspection
_save_json
(
filename
,
parameters
,
result_dict
)
def
save_and_check_dict
(
data
,
filename
,
generate_golden
=
False
):
"""
Save the dataset dictionary and compare (as dictionary) with golden file.
...
...
@@ -203,6 +167,29 @@ def save_and_check_tuple(data, parameters, filename, generate_golden=False):
_save_json
(
filename
,
parameters
,
result_dict
)
def
config_get_set_seed
(
seed_new
):
"""
Get and return the original configuration seed value.
Set the new configuration seed value.
"""
seed_original
=
ds
.
config
.
get_seed
()
ds
.
config
.
set_seed
(
seed_new
)
logger
.
info
(
"seed: original = {} new = {} "
.
format
(
seed_original
,
seed_new
))
return
seed_original
def
config_get_set_num_parallel_workers
(
num_parallel_workers_new
):
"""
Get and return the original configuration num_parallel_workers value.
Set the new configuration num_parallel_workers value.
"""
num_parallel_workers_original
=
ds
.
config
.
get_num_parallel_workers
()
ds
.
config
.
set_num_parallel_workers
(
num_parallel_workers_new
)
logger
.
info
(
"num_parallel_workers: original = {} new = {} "
.
format
(
num_parallel_workers_original
,
num_parallel_workers_new
))
return
num_parallel_workers_original
def
diff_mse
(
in1
,
in2
):
mse
=
(
np
.
square
(
in1
.
astype
(
float
)
/
255
-
in2
.
astype
(
float
)
/
255
)).
mean
()
return
mse
*
100
...
...
@@ -265,29 +252,6 @@ def visualize_image(image_original, image_de, mse=None, image_lib=None):
plt
.
show
()
def
config_get_set_seed
(
seed_new
):
"""
Get and return the original configuration seed value.
Set the new configuration seed value.
"""
seed_original
=
ds
.
config
.
get_seed
()
ds
.
config
.
set_seed
(
seed_new
)
logger
.
info
(
"seed: original = {} new = {} "
.
format
(
seed_original
,
seed_new
))
return
seed_original
def
config_get_set_num_parallel_workers
(
num_parallel_workers_new
):
"""
Get and return the original configuration num_parallel_workers value.
Set the new configuration num_parallel_workers value.
"""
num_parallel_workers_original
=
ds
.
config
.
get_num_parallel_workers
()
ds
.
config
.
set_num_parallel_workers
(
num_parallel_workers_new
)
logger
.
info
(
"num_parallel_workers: original = {} new = {} "
.
format
(
num_parallel_workers_original
,
num_parallel_workers_new
))
return
num_parallel_workers_original
def
visualize_with_bounding_boxes
(
orig
,
aug
,
annot_name
=
"annotation"
,
plot_rows
=
3
):
"""
Take a list of un-augmented and augmented images with "annotation" bounding boxes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录