TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tf.distribute.get_strategy

TensorFlow 1 version View source on GitHub

Returns the current tf.distribute.Strategy object.

Aliases:

tf.distribute.get_strategy()

Typically only used in a cross-replica context:

if tf.distribute.in_cross_replica_context():
  strategy = tf.distribute.get_strategy()
  ...

Returns:

A tf.distribute.Strategy object. Inside a with strategy.scope() block, it returns strategy, otherwise it returns the default (single-replica) tf.distribute.Strategy object.