tf.compat.v1.layers.experimental.set_keras_style
Использование управления переменными в стиле Keras.
tf.compat.v1.layers.experimental.set_keras_style()
Все tf.layers и tf RNN ячейки, созданные после включения стиля Keras, используют управление переменными в стиле Keras. Создание таких слоев с аргументом scope= запрещено, а также запрещено использование reuse=True.
Цель этой функции — позволить пользователям существующих слоев постепенно переходить к API слоев Keras, не нарушая существующую функциональность.
Для получения более подробной информации см. документацию для keras_style_scope.
Обратите внимание, что после установки стиля Keras он устанавливается глобально для всей программы и его нельзя сбросить.
Пример:
set_keras_style() model_1 = RNNModel(name="model_1") model_2 = RNNModel(name="model_2") # model_1 and model_2 are guaranteed to create their own variables. output_1, next_state_1 = model_1(input, state) output_2, next_state_2 = model_2(input, state) assert len(model_1.weights) > 0 assert len(model_2.weights) > 0 assert(model_1.weights != model_2.weights)
© 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/versions/r2.9/api_docs/python/tf/compat/v1/layers/experimental/set_keras_style