简体   繁体   English

如何在自定义训练循环中使用 tf.keras.layers.BatchNormalization()?

[英]How to use the tf.keras.layers.BatchNormalization() in custom training loop?

I went back to tensorflow after quite a while and it seems the landscape is completely changed.过了一会儿,我又回到了 tensorflow,看起来情况已经完全改变了。

However, previously I used to use tf.contrib....batch_normalization with the following in the training loop:但是,以前我曾经在训练循环中使用tf.contrib....batch_normalization和以下内容:

update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
    train_op = optimizer.minimize(cnn.loss, global_step=global_step)

But it seems, contrib is nowhere to be found and tf.keras.layers.BatchNormalization does not work the same way.但似乎contrib无处可寻,并且tf.keras.layers.BatchNormalization的工作方式不同。 Also, I couldn't find any training instruction in their documentation .另外,我在他们的文档中找不到任何培训说明。

So, any information of help is appreciated.因此,感谢任何帮助信息。

I started using pyTorch.我开始使用 pyTorch。 It solved the problem.它解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何正确使用tf.keras.layers.BatchNormalization进行训练:是否仍然存在tf.GraphKeys.UPDATE_OPS依赖项? - How to correctly train with tf.keras.layers.BatchNormalization: Is there still a tf.GraphKeys.UPDATE_OPS dependency? 有人可以解释 tf.keras.layers.BatchNormalization 的行为吗? - Can someone explain the behaviour of tf.keras.layers.BatchNormalization? 如何在自定义 Keras 模型中使用 BatchNormalization 层 - How to use BatchNormalization layers in customize Keras Model 使用 tf.keras.layers.concatenate() 作为 tensorflow 中的自定义层 - Use tf.keras.layers.concatenate() as custom layer in tensorflow 如何在自定义 tf.keras.layers.Layer 中支持遮罩 - How to support masking in custom tf.keras.layers.Layer 如何对自定义 Keras 层进行故障排除 - How to troubleshoot custom Keras layers 如何将 tf.keras.layers.Normalization 用于模型中的多个特征 - How to use tf.keras.layers.Normalization for more than one feature inside the model How can I use tf.keras.Model.summary to see the layers of a child model which in a father model? - How can I use tf.keras.Model.summary to see the layers of a child model which in a father model? 无法将带有自定义层的 keras 模型保存到 tf lite 文件 - Cannot save keras model with custom layers to tf lite file 使用 tf.keras.Model.fit 进行训练时如何将自定义摘要添加到 tensorboard - How to add custom summaries to tensorboard when training with tf.keras.Model.fit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM