Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
09433cdd
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看板
提交
09433cdd
编写于
6月 09, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
6月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1883 Change '%d' to '%r': shape is a tuple, not a integer
Merge pull request !1883 from 李鸿章/fix_type_error
上级
f6b5b273
ccf49b7c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
16 deletion
+15
-16
mindspore/train/summary/_summary_adapter.py
mindspore/train/summary/_summary_adapter.py
+15
-16
未找到文件。
mindspore/train/summary/_summary_adapter.py
浏览文件 @
09433cdd
...
...
@@ -113,7 +113,7 @@ def package_summary_event(data_list, step):
data
=
value
[
"data"
]
tag
=
value
[
"name"
]
logger
.
debug
(
"Now process %r summary, tag = %r"
,
summary_type
,
tag
)
logger
.
debug
(
f
"Now process
{
summary_type
}
summary, tag =
{
tag
}
"
)
summary_value
=
summary
.
value
.
add
()
summary_value
.
tag
=
tag
...
...
@@ -130,7 +130,7 @@ def package_summary_event(data_list, step):
_fill_histogram_summary
(
tag
,
data
,
summary_value
.
histogram
)
else
:
# The data is invalid ,jump the data
logger
.
error
(
"Summary type(%r) is error, tag = %r"
,
summary_type
,
tag
)
logger
.
error
(
f
"Summary type(
{
summary_type
}
) is error, tag =
{
tag
}
"
)
del
summary
.
value
[
-
1
]
return
summary_event
...
...
@@ -186,17 +186,17 @@ def _fill_scalar_summary(tag: str, np_value, summary):
Returns:
Summary, return scalar summary content.
"""
logger
.
debug
(
"Set(%r) the scalar summary value"
,
tag
)
logger
.
debug
(
f
"Set(
{
tag
}
) the scalar summary value"
)
if
np_value
.
size
==
1
:
# is scalar
summary
.
scalar_value
=
np_value
.
item
()
return
True
if
np_value
.
size
>
1
:
logger
.
warning
(
"The tensor is not a single scalar, tag = %r, ndim = %r, shape = %r"
,
tag
,
np_value
.
ndim
,
np_value
.
shape
)
logger
.
warning
(
f
"The tensor is not a single scalar, tag =
{
tag
}
, ndim =
{
np_value
.
ndim
}
, shape =
{
np_value
.
shape
}
"
)
summary
.
scalar_value
=
next
(
np_value
.
flat
).
item
()
return
True
logger
.
error
(
"There no values inside tensor, tag = %r, size = %r"
,
tag
,
np_value
.
size
)
logger
.
error
(
f
"There no values inside tensor, tag =
{
tag
}
, size =
{
np_value
.
size
}
"
)
return
False
...
...
@@ -212,7 +212,7 @@ def _fill_tensor_summary(tag: str, np_value, summary_tensor):
Retruns:
Summary, return tensor summary content.
"""
logger
.
debug
(
"Set(%r) the tensor summary value"
,
tag
)
logger
.
debug
(
f
"Set(
{
tag
}
) the tensor summary value"
)
# get tensor dtype
tensor_dtype
=
_nptype_to_prototype
(
np_value
)
summary_tensor
.
data_type
=
DataType
.
Value
(
tensor_dtype
)
...
...
@@ -266,7 +266,7 @@ def _fill_histogram_summary(tag: str, np_value: np.ndarray, summary) -> None:
np_value (np.ndarray): Summary data.
summary (summary_pb2.Summary.Histogram): Summary histogram data.
"""
logger
.
debug
(
"Set(%r) the histogram summary value"
,
tag
)
logger
.
debug
(
f
"Set(
{
tag
}
) the histogram summary value"
)
# Default bucket for tensor with no valid data.
ma_value
=
np
.
ma
.
masked_invalid
(
np_value
)
total
,
valid
=
np_value
.
size
,
ma_value
.
count
()
...
...
@@ -281,7 +281,7 @@ def _fill_histogram_summary(tag: str, np_value: np.ndarray, summary) -> None:
summary
.
count
=
total
summary
.
nan_count
,
summary
.
pos_inf_count
,
summary
.
neg_inf_count
=
invalids
if
not
valid
:
logger
.
warning
(
'There are no valid values in the ndarray(size=%d, shape=%d)'
,
total
,
np_value
.
shape
)
logger
.
warning
(
f
'There are no valid values in the ndarray(size=
{
total
}
, shape=
{
np_value
.
shape
}
)'
)
# summary.{min, max, sum} are 0s by default, no need to explicitly set
else
:
# BUG: max of a masked array with dtype np.float16 returns inf
...
...
@@ -290,9 +290,8 @@ def _fill_histogram_summary(tag: str, np_value: np.ndarray, summary) -> None:
summary
.
min
=
ma_value
.
min
(
fill_value
=
np
.
PINF
)
summary
.
max
=
ma_value
.
max
(
fill_value
=
np
.
NINF
)
if
summary
.
min
<
F32_MIN
or
summary
.
max
>
F32_MAX
:
logger
.
warning
(
'Values(%r, %r) are too large, '
'you may encounter some undefined behaviours hereafter.'
,
summary
.
min
,
summary
.
max
)
logger
.
warning
(
f
'Values(
{
summary
.
min
}
,
{
summary
.
max
}
) are too large, '
f
'you may encounter some undefined behaviours hereafter.'
)
else
:
summary
.
min
=
ma_value
.
min
()
summary
.
max
=
ma_value
.
max
()
...
...
@@ -327,14 +326,14 @@ def _fill_image_summary(tag: str, np_value, summary_image, input_format='NCHW'):
Returns:
Summary, return image summary content.
"""
logger
.
debug
(
"Set(%r) the image summary value"
,
tag
)
logger
.
debug
(
f
"Set(
{
tag
}
) the image summary value"
)
if
np_value
.
ndim
!=
4
or
np_value
.
shape
[
1
]
not
in
(
1
,
3
):
logger
.
error
(
"The value is not Image, tag = %r, ndim = %r, shape=%r"
,
tag
,
np_value
.
ndim
,
np_value
.
shape
)
logger
.
error
(
f
"The value is not Image, tag =
{
tag
}
, ndim =
{
np_value
.
ndim
}
, shape=
{
np_value
.
shape
}
"
)
return
False
if
np_value
.
ndim
!=
len
(
input_format
):
logger
.
error
(
"The tensor with dim(%r) can't convert the format(%r) because dim not same"
,
np_value
.
ndim
,
input_format
)
logger
.
error
(
f
"The tensor with dim(
{
np_value
.
ndim
}
) can't convert the format(
{
input_format
}
) because dim not same"
)
return
False
# convert the tensor format
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录