Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38905368
tensorflow
提交
8b5a12a1
T
tensorflow
项目概览
qq_38905368
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8b5a12a1
编写于
2月 25, 2019
作者:
T
Tom Hennigan
提交者:
TensorFlower Gardener
2月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make V1 and V2 VariableAggregation enums interchangeable.
PiperOrigin-RevId: 235518682
上级
2e1ea487
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
44 addition
and
4 deletion
+44
-4
tensorflow/python/distribute/mirrored_strategy.py
tensorflow/python/distribute/mirrored_strategy.py
+6
-4
tensorflow/python/kernel_tests/variables_test.py
tensorflow/python/kernel_tests/variables_test.py
+24
-0
tensorflow/python/ops/variables.py
tensorflow/python/ops/variables.py
+14
-0
未找到文件。
tensorflow/python/distribute/mirrored_strategy.py
浏览文件 @
8b5a12a1
...
...
@@ -220,8 +220,9 @@ def _create_mirrored_variable(strategy, device_map, logical_device, # pylint: d
# `AUTO` synchronization for `MirroredStrategy` is `ON_WRITE`.
is_replica_local
=
False
else
:
raise
ValueError
(
"Invalid variable synchronization mode: "
+
synchronization
+
" for variable: "
+
kwargs
[
"name"
])
raise
ValueError
(
"Invalid variable synchronization mode: %s for variable: %s"
%
(
synchronization
,
kwargs
[
"name"
]))
# Get aggregation value
aggregation
=
kwargs
.
pop
(
"aggregation"
,
...
...
@@ -232,8 +233,9 @@ def _create_mirrored_variable(strategy, device_map, logical_device, # pylint: d
variable_scope
.
VariableAggregation
.
MEAN
,
variable_scope
.
VariableAggregation
.
ONLY_FIRST_REPLICA
):
raise
ValueError
(
"Invalid variable aggregation mode: "
+
aggregation
+
" for variable: "
+
kwargs
[
"name"
])
raise
ValueError
(
"Invalid variable aggregation mode: %s for variable: %s"
%
(
aggregation
,
kwargs
[
"name"
]))
# Ignore user-specified caching device, not needed for mirrored variables.
kwargs
.
pop
(
"caching_device"
,
None
)
...
...
tensorflow/python/kernel_tests/variables_test.py
浏览文件 @
8b5a12a1
...
...
@@ -828,5 +828,29 @@ class VariableContainerTest(test.TestCase):
self
.
assertEqual
(
compat
.
as_bytes
(
""
),
v4
.
op
.
get_attr
(
"container"
))
class
AggregationModesTest
(
test
.
TestCase
):
def
testV1V2Equal
(
self
):
v1
=
variables
.
VariableAggregation
v2
=
variables
.
VariableAggregationV2
self
.
assertEqual
(
v1
.
NONE
,
v2
.
NONE
)
self
.
assertEqual
(
v1
.
SUM
,
v2
.
SUM
)
self
.
assertEqual
(
v1
.
MEAN
,
v2
.
MEAN
)
self
.
assertEqual
(
v1
.
ONLY_FIRST_REPLICA
,
v2
.
ONLY_FIRST_REPLICA
)
self
.
assertEqual
(
v1
.
ONLY_FIRST_TOWER
,
v2
.
ONLY_FIRST_REPLICA
)
self
.
assertEqual
(
v2
.
NONE
,
v1
.
NONE
)
self
.
assertEqual
(
v2
.
SUM
,
v1
.
SUM
)
self
.
assertEqual
(
v2
.
MEAN
,
v1
.
MEAN
)
self
.
assertEqual
(
v2
.
ONLY_FIRST_REPLICA
,
v1
.
ONLY_FIRST_REPLICA
)
self
.
assertEqual
(
v2
.
ONLY_FIRST_REPLICA
,
v1
.
ONLY_FIRST_TOWER
)
self
.
assertEqual
(
hash
(
v1
.
NONE
),
hash
(
v2
.
NONE
))
self
.
assertEqual
(
hash
(
v1
.
SUM
),
hash
(
v2
.
SUM
))
self
.
assertEqual
(
hash
(
v1
.
MEAN
),
hash
(
v2
.
MEAN
))
self
.
assertEqual
(
hash
(
v1
.
ONLY_FIRST_REPLICA
),
hash
(
v2
.
ONLY_FIRST_REPLICA
))
self
.
assertEqual
(
hash
(
v1
.
ONLY_FIRST_TOWER
),
hash
(
v2
.
ONLY_FIRST_REPLICA
))
if
__name__
==
"__main__"
:
test
.
main
()
tensorflow/python/ops/variables.py
浏览文件 @
8b5a12a1
...
...
@@ -103,6 +103,17 @@ class VariableAggregationV2(enum.Enum):
MEAN
=
2
ONLY_FIRST_REPLICA
=
3
def
__hash__
(
self
):
return
hash
(
self
.
value
)
def
__eq__
(
self
,
other
):
if
self
is
other
:
return
True
elif
isinstance
(
other
,
VariableAggregation
):
return
int
(
self
.
value
)
==
int
(
other
.
value
)
else
:
return
False
@
tf_export
(
v1
=
[
"VariableAggregation"
])
class
VariableAggregation
(
enum
.
Enum
):
...
...
@@ -112,6 +123,9 @@ class VariableAggregation(enum.Enum):
ONLY_FIRST_REPLICA
=
3
ONLY_FIRST_TOWER
=
3
# DEPRECATED
def
__hash__
(
self
):
return
hash
(
self
.
value
)
VariableAggregation
.
__doc__
=
(
VariableAggregationV2
.
__doc__
+
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录