tf.distribute.in_cross_replica_context

View source on GitHub

Returns True if in a cross-replica context.

See tf.distribute.get_replica_context for details.

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)
Returns
True if in a cross-replica context (get_replica_context() returns None), or False if in a replica context (get_replica_context() returns non-None).

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/distribute/in_cross_replica_context