使用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)
相关用法
- Python tf.compat.v1.layers.experimental.keras_style_scope用法及代码示例
- Python tf.compat.v1.layers.conv3d用法及代码示例
- Python tf.compat.v1.layers.Conv3D用法及代码示例
- Python tf.compat.v1.layers.dense用法及代码示例
- Python tf.compat.v1.layers.AveragePooling3D用法及代码示例
- Python tf.compat.v1.layers.Conv2DTranspose用法及代码示例
- Python tf.compat.v1.layers.max_pooling3d用法及代码示例
- Python tf.compat.v1.layers.average_pooling1d用法及代码示例
- Python tf.compat.v1.layers.flatten用法及代码示例
- Python tf.compat.v1.layers.conv1d用法及代码示例
- Python tf.compat.v1.layers.conv2d_transpose用法及代码示例
- Python tf.compat.v1.layers.dropout用法及代码示例
- Python tf.compat.v1.layers.batch_normalization用法及代码示例
- Python tf.compat.v1.layers.average_pooling2d用法及代码示例
- Python tf.compat.v1.layers.MaxPooling1D用法及代码示例
- Python tf.compat.v1.layers.conv2d用法及代码示例
- Python tf.compat.v1.layers.Conv2D用法及代码示例
- Python tf.compat.v1.layers.AveragePooling1D用法及代码示例
- Python tf.compat.v1.layers.BatchNormalization用法及代码示例
- Python tf.compat.v1.layers.max_pooling1d用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.layers.experimental.set_keras_style。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
