Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_40195168达庆意
keras
提交
3f90361f
K
keras
项目概览
weixin_40195168达庆意
/
keras
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
keras
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f90361f
编写于
6月 22, 2021
作者:
E
Evan Rosen
提交者:
TensorFlower Gardener
6月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid serializing generated thresholds for AUC metrics.
PiperOrigin-RevId: 380933127
上级
5d2663ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
4 deletion
+9
-4
keras/metrics.py
keras/metrics.py
+7
-4
keras/metrics_confusion_matrix_test.py
keras/metrics_confusion_matrix_test.py
+2
-0
未找到文件。
keras/metrics.py
浏览文件 @
3f90361f
...
...
@@ -2116,6 +2116,7 @@ class AUC(Metric):
summation_method
,
list
(
metrics_utils
.
AUCSummationMethod
)))
# Update properties.
self
.
_init_from_thresholds
=
thresholds
is
not
None
if
thresholds
is
not
None
:
# If specified, use the supplied thresholds.
self
.
num_thresholds
=
len
(
thresholds
)
+
2
...
...
@@ -2444,13 +2445,15 @@ class AUC(Metric):
'num_thresholds'
:
self
.
num_thresholds
,
'curve'
:
self
.
curve
.
value
,
'summation_method'
:
self
.
summation_method
.
value
,
# We remove the endpoint thresholds as an inverse of how the thresholds
# were initialized. This ensures that a metric initialized from this
# config has the same thresholds.
'thresholds'
:
self
.
thresholds
[
1
:
-
1
],
'multi_label'
:
self
.
multi_label
,
'label_weights'
:
label_weights
}
# optimization to avoid serializing a large number of generated thresholds
if
self
.
_init_from_thresholds
:
# We remove the endpoint thresholds as an inverse of how the thresholds
# were initialized. This ensures that a metric initialized from this
# config has the same thresholds.
config
[
'thresholds'
]
=
self
.
thresholds
[
1
:
-
1
]
base_config
=
super
(
AUC
,
self
).
get_config
()
return
dict
(
list
(
base_config
.
items
())
+
list
(
config
.
items
()))
...
...
keras/metrics_confusion_matrix_test.py
浏览文件 @
3f90361f
...
...
@@ -1237,6 +1237,7 @@ class AUCTest(tf.test.TestCase, parameterized.TestCase):
self
.
assertEqual
(
auc_obj
.
summation_method
,
metrics_utils
.
AUCSummationMethod
.
MAJORING
)
old_config
=
auc_obj
.
get_config
()
self
.
assertNotIn
(
'thresholds'
,
old_config
)
self
.
assertDictEqual
(
old_config
,
json
.
loads
(
json
.
dumps
(
old_config
)))
# Check save and restore config.
...
...
@@ -1249,6 +1250,7 @@ class AUCTest(tf.test.TestCase, parameterized.TestCase):
self
.
assertEqual
(
auc_obj2
.
summation_method
,
metrics_utils
.
AUCSummationMethod
.
MAJORING
)
new_config
=
auc_obj2
.
get_config
()
self
.
assertNotIn
(
'thresholds'
,
new_config
)
self
.
assertDictEqual
(
old_config
,
new_config
)
self
.
assertAllClose
(
auc_obj
.
thresholds
,
auc_obj2
.
thresholds
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录