tf.distribute.experimental_set_strategy
| Просмотреть исходный код на GitHub |
Установить tf.distribute.Strategy в качестве текущего без with strategy.scope().
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()
эквивалентно:
with strategy1.scope(): f() with strategy2.scope(): g() h()
В общем случае, вы должны использовать with strategy.scope(): API, но этот альтернативный способ может быть удобен в ноутбуках, где вам необходимо поместить каждый блок кода в with strategy.scope(): блок.
Примечание: Это должно вызываться только вне любого контекста TensorFlow, чтобы избежать неправильного вложенного вызова.
| Аргументы | |
|---|---|
strategy | Объект tf.distribute.Strategy или None. |
| Исключения | |
|---|---|
RuntimeError | Если вызвано внутри with strategy.scope():. |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/distribute/experimental_set_strategy