当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tf.compat.v1.layers.experimental.set_keras_style用法及代码示例


使用Keras-style 变量管理。

用法

tf.compat.v1.layers.experimental.set_keras_style()

启用 keras 样式后创建的所有 tf​​.layers 和 tf RNN 单元都使用Keras-style 变量管理。不允许使用 scope= 参数创建此类层,并且不允许使用 reuse=True。

此函数的目的是允许现有层的用户在不破坏现有函数的情况下缓慢过渡到 Keras 层 API。

有关更多详细信息,请参阅 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)

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.layers.experimental.set_keras_style。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。