Missed TensorFlow World? Check out the recap. Learn more

tf.distribute.has_strategy

TensorFlow 2 version View source on GitHub

Return if there is a current non-default tf.distribute.Strategy.

Aliases:

tf.distribute.has_strategy()
assert not tf.distribute.has_strategy()
with strategy.scope():
  assert tf.distribute.has_strategy()

Returns:

True if inside a with strategy.scope():.