当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python tf.distribute.in_cross_replica_context用法及代码示例

如果在 cross-replica 上下文中,则返回 True

用法

tf.distribute.in_cross_replica_context()

返回

  • True 如果在 cross-replica 上下文中(get_replica_context() 返回 None),或者 False 如果在副本上下文中(get_replica_context() 返回非 None)。

有关详细信息,请参阅tf.distribute.get_replica_context

assert not tf.distribute.in_cross_replica_context()
with strategy.scope():
  assert tf.distribute.in_cross_replica_context()

  def f():
    assert not tf.distribute.in_cross_replica_context()

  strategy.run(f)

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.distribute.in_cross_replica_context。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。