Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
f6f80fae
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
7
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6f80fae
编写于
5月 23, 2020
作者:
L
luopengting
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix calculation of lineage dataset_num, get model name
上级
169c580a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
37 deletion
+41
-37
mindinsight/lineagemgr/collection/model/model_lineage.py
mindinsight/lineagemgr/collection/model/model_lineage.py
+28
-29
mindinsight/lineagemgr/querier/query_model.py
mindinsight/lineagemgr/querier/query_model.py
+0
-1
tests/st/func/lineagemgr/api/test_model_api.py
tests/st/func/lineagemgr/api/test_model_api.py
+5
-5
tests/ut/lineagemgr/collection/model/test_model_lineage.py
tests/ut/lineagemgr/collection/model/test_model_lineage.py
+4
-2
tests/utils/mindspore/dataset/engine/datasets.py
tests/utils/mindspore/dataset/engine/datasets.py
+4
-0
未找到文件。
mindinsight/lineagemgr/collection/model/model_lineage.py
浏览文件 @
f6f80fae
...
...
@@ -37,7 +37,7 @@ from mindinsight.lineagemgr.collection.model.base import Metadata
try
:
from
mindspore.common.tensor
import
Tensor
from
mindspore.train.callback
import
Callback
,
RunContext
,
ModelCheckpoint
,
SummaryStep
from
mindspore.nn
import
Cell
,
Optimizer
,
WithLossCell
,
TrainOneStepWithLossScaleCell
from
mindspore.nn
import
Cell
,
Optimizer
from
mindspore.nn.loss.loss
import
_Loss
from
mindspore.dataset.engine
import
Dataset
,
MindDataset
import
mindspore.dataset
as
ds
...
...
@@ -412,27 +412,28 @@ class AnalyzeObject:
Returns:
str, the name of the backbone network.
"""
with_loss_cell
=
False
backbone
=
None
backbone_name
=
None
has_network
=
False
network_key
=
'network'
backbone_key
=
'_backbone'
net_args
=
vars
(
network
)
if
network
else
{}
net_cell
=
net_args
.
get
(
'_cells'
)
if
net_args
else
{}
for
_
,
value
in
net_cell
.
items
():
if
isinstance
(
value
,
WithLossCell
)
:
backbone
=
getattr
(
value
,
'_backbone'
)
with_loss_cell
=
True
for
key
,
value
in
net_cell
.
items
():
if
key
==
network_key
:
network
=
value
has_network
=
True
break
if
with_loss_cell
:
backbone_name
=
type
(
backbone
).
__name__
\
if
backbone
else
None
elif
isinstance
(
network
,
TrainOneStepWithLossScaleCell
):
backbone
=
getattr
(
network
,
'network'
)
backbone_name
=
type
(
backbone
).
__name__
\
if
backbone
else
None
else
:
backbone_name
=
type
(
network
).
__name__
\
if
network
else
None
if
has_network
:
while
hasattr
(
network
,
network_key
):
network
=
getattr
(
network
,
network_key
)
if
hasattr
(
network
,
backbone_key
):
backbone
=
getattr
(
network
,
backbone_key
)
backbone_name
=
type
(
backbone
).
__name__
elif
network
is
not
None
:
backbone_name
=
type
(
network
).
__name__
return
backbone_name
@
staticmethod
...
...
@@ -489,26 +490,24 @@ class AnalyzeObject:
Returns:
dict, the lineage metadata.
"""
dataset_batch_size
=
dataset
.
get_dataset_size
()
if
dataset_batch_size
is
not
None
:
validate_int_params
(
dataset_batch_size
,
'dataset_batch_size'
)
log
.
debug
(
'dataset_batch_size: %d'
,
dataset_batch_size
)
batch_num
=
dataset
.
get_dataset_size
()
batch_size
=
dataset
.
get_batch_size
()
if
batch_num
is
not
None
:
validate_int_params
(
batch_num
,
'dataset_batch_num'
)
validate_int_params
(
batch_num
,
'dataset_batch_size'
)
log
.
debug
(
'dataset_batch_num: %d'
,
batch_num
)
log
.
debug
(
'dataset_batch_size: %d'
,
batch_size
)
dataset_path
=
AnalyzeObject
.
get_dataset_path_wrapped
(
dataset
)
if
dataset_path
:
dataset_path
=
'/'
.
join
(
dataset_path
.
split
(
'/'
)[:
-
1
])
step_num
=
lineage_dict
.
get
(
'step_num'
)
validate_int_params
(
step_num
,
'step_num'
)
log
.
debug
(
'step_num: %d'
,
step_num
)
dataset_size
=
int
(
batch_num
*
batch_size
)
if
dataset_type
==
'train'
:
lineage_dict
[
Metadata
.
train_dataset_path
]
=
dataset_path
epoch
=
lineage_dict
.
get
(
'epoch'
)
train_dataset_size
=
dataset_batch_size
*
(
step_num
/
epoch
)
lineage_dict
[
Metadata
.
train_dataset_size
]
=
int
(
train_dataset_size
)
lineage_dict
[
Metadata
.
train_dataset_size
]
=
dataset_size
elif
dataset_type
==
'valid'
:
lineage_dict
[
Metadata
.
valid_dataset_path
]
=
dataset_path
lineage_dict
[
Metadata
.
valid_dataset_size
]
=
dataset_
batch_size
*
step_num
lineage_dict
[
Metadata
.
valid_dataset_size
]
=
dataset_
size
return
lineage_dict
...
...
mindinsight/lineagemgr/querier/query_model.py
浏览文件 @
f6f80fae
...
...
@@ -82,7 +82,6 @@ class LineageObj:
self
.
_lineage_info
=
{
self
.
_name_summary_dir
:
summary_dir
}
self
.
_filtration_result
=
None
self
.
_init_lineage
()
self
.
parse_and_update_lineage
(
**
kwargs
)
...
...
tests/st/func/lineagemgr/api/test_model_api.py
浏览文件 @
f6f80fae
...
...
@@ -50,10 +50,10 @@ LINEAGE_INFO_RUN1 = {
'network'
:
'ResNet'
},
'train_dataset'
:
{
'train_dataset_size'
:
731
'train_dataset_size'
:
1024
},
'valid_dataset'
:
{
'valid_dataset_size'
:
1024
0
'valid_dataset_size'
:
1024
},
'model'
:
{
'path'
:
'{"ckpt": "'
...
...
@@ -89,9 +89,9 @@ LINEAGE_FILTRATION_RUN1 = {
'model_lineage'
:
{
'loss_function'
:
'SoftmaxCrossEntropyWithLogits'
,
'train_dataset_path'
:
None
,
'train_dataset_count'
:
731
,
'train_dataset_count'
:
1024
,
'test_dataset_path'
:
None
,
'test_dataset_count'
:
1024
0
,
'test_dataset_count'
:
1024
,
'user_defined'
:
{},
'network'
:
'ResNet'
,
'optimizer'
:
'Momentum'
,
...
...
@@ -115,7 +115,7 @@ LINEAGE_FILTRATION_RUN2 = {
'train_dataset_path'
:
None
,
'train_dataset_count'
:
1024
,
'test_dataset_path'
:
None
,
'test_dataset_count'
:
1024
0
,
'test_dataset_count'
:
1024
,
'user_defined'
:
{},
'network'
:
"ResNet"
,
'optimizer'
:
"Momentum"
,
...
...
tests/ut/lineagemgr/collection/model/test_model_lineage.py
浏览文件 @
f6f80fae
...
...
@@ -334,12 +334,14 @@ class TestAnalyzer(TestCase):
)
res1
=
self
.
analyzer
.
analyze_dataset
(
dataset
,
{
'step_num'
:
10
,
'epoch'
:
2
},
'train'
)
res2
=
self
.
analyzer
.
analyze_dataset
(
dataset
,
{
'step_num'
:
5
},
'valid'
)
# batch_size is mocked as 32.
assert
res1
==
{
'step_num'
:
10
,
'train_dataset_path'
:
'/path/to'
,
'train_dataset_size'
:
5
0
,
'train_dataset_size'
:
32
0
,
'epoch'
:
2
}
assert
res2
==
{
'step_num'
:
5
,
'valid_dataset_path'
:
'/path/to'
,
'valid_dataset_size'
:
5
0
}
'valid_dataset_size'
:
32
0
}
def
test_get_dataset_path_dataset
(
self
):
"""Test get_dataset_path method with Dataset."""
...
...
tests/utils/mindspore/dataset/engine/datasets.py
浏览文件 @
f6f80fae
...
...
@@ -27,6 +27,10 @@ class Dataset:
"""Mocked get_dataset_size."""
return
self
.
dataset_size
def
get_batch_size
(
self
):
"""Mocked get_batch_size"""
return
32
class
MindDataset
(
Dataset
):
"""Mock the MindSpore MindDataset class."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录