當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。