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

tf.distribute.experimental_set_strategy

TensorFlow 2.0 version View source on GitHub

Set a tf.distribute.Strategy as current without with strategy.scope().

Aliases:

  • tf.compat.v1.distribute.experimental_set_strategy
  • tf.compat.v2.distribute.experimental_set_strategy
tf.distribute.experimental_set_strategy(strategy)
tf.distribute.experimental_set_strategy(strategy1)
f()
tf.distribute.experimental_set_strategy(strategy2)
g()
tf.distribute.experimental_set_strategy(None)
h()

is equivalent to:

with strategy1.scope():
  f()
with strategy2.scope():
  g()
h()

In general, you should use the with strategy.scope(): API, but this alternative may be convenient in notebooks where you would have to put each cell in a with strategy.scope(): block.

Args:

Raises:

  • RuntimeError: If called inside a with strategy.scope():.