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