Join us at TensorFlow World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tf.contrib.distribute.get_cross_replica_context

View source on GitHub

Returns the current tf.distribute.Strategy if in a cross-replica context.

tf.contrib.distribute.get_cross_replica_context()

DEPRECATED: Please use in_cross_replica_context() and get_strategy() instead.

Note that execution:

  1. starts in the default (single-replica) replica context;
  2. switches to cross-replica context when entering a with tf.distribute.Strategy.scope(): block;
  3. switches to a (non-default) replica context inside call_for_each_replica(fn, ...);
  4. if fn calls get_replica_context()->merge_call(merge_fn, ...), then inside merge_fn you are back in the cross-replica context.

Note that you can also go directly from step 1 to 4 to switch to a cross-replica context for the default tf.distribute.Strategy. You may also switch from the cross-replica context of 4 to a replica context by calling call_for_each_replica(), jumping back to step 3.

Most tf.distribute.Strategy methods may only be executed in a cross-replica context.

Returns:

Returns the current tf.distribute.Strategy object in a cross-replica context, or None.

Exactly one of get_replica_context() and get_cross_replica_context() will return None in a particular block.