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.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.distribute.experimental_set_strategy\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 2 version](/api_docs/python/tf/distribute/experimental_set_strategy) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/distribute/distribution_strategy_context.py#L220-L266) |\n\nSet a [`tf.distribute.Strategy`](../../tf/distribute/Strategy) as current without `with strategy.scope()`.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.distribute.experimental_set_strategy`](/api_docs/python/tf/distribute/experimental_set_strategy), \\`tf.compat.v2.distribute.experimental_set_strategy\\`\n\n\u003cbr /\u003e\n\n tf.distribute.experimental_set_strategy(\n strategy\n )\n\n tf.distribute.experimental_set_strategy(strategy1)\n f()\n tf.distribute.experimental_set_strategy(strategy2)\n g()\n tf.distribute.experimental_set_strategy(None)\n h()\n\nis equivalent to: \n\n with strategy1.scope():\n f()\n with strategy2.scope():\n g()\n h()\n\nIn general, you should use the `with strategy.scope():` API, but this\nalternative may be convenient in notebooks where you would have to put\neach cell in a `with strategy.scope():` block.\n| **Note:** This should only be called outside of any TensorFlow scope to avoid improper nesting.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|----------------------------------------------------------------------------|\n| `strategy` | A [`tf.distribute.Strategy`](../../tf/distribute/Strategy) object or None. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|----------------|----------------------------------------------|\n| `RuntimeError` | If called inside a `with strategy.scope():`. |\n\n\u003cbr /\u003e"]]