Missed TensorFlow World? Check out the recap. Learn more

tf.distribute.get_strategy

Aliases:

  • tf.contrib.distribute.get_distribution_strategy
  • tf.distribute.get_strategy
tf.distribute.get_strategy()

Defined in tensorflow/python/distribute/distribution_strategy_context.py.

Returns the current tf.distribute.Strategy object.

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 distribution_strategy.scope() block, it returns distribution_strategy, otherwise it returns the default (single-replica) tf.distribute.Strategy object.