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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[],null,["# tf.distribute.experimental_set_strategy\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/distribute/distribute_lib.py#L581-L627) |\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`](https://www.tensorflow.org/api_docs/python/tf/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"]]