简体   繁体   English

Keras错误:“BatchNormalization Shape必须为1级,但batch_normal化为rank 4”

[英]Keras error: “BatchNormalization Shape must be rank 1 but is rank 4 for batch_normalization”

I have a Keras functional model (Neural network with convolutional layers) which works fine with tensorflow. 我有一个Keras功能模型(带卷积层的神经网络),它可以很好地处理张量流。 I can run it and I can fit it. 我可以运行它,我可以适应它。

However, the model cannot be built when tensorflow gpu is used. 但是,当使用tensorflow gpu时,无法构建模型。

This is the line of the code when building the model which throws the error. 这是构建抛出错误的模型时的代码行。

x = BatchNormalization(axis=1)(x)

And the error message is " BatchNormalization Shape must be rank 1 but is rank 4 for batch_normalization ". 并且错误消息是“ BatchNormalization Shape必须为1级,但批次标准化为4级 ”。

It seems to me that it is a bug in Keras. 在我看来,它是Keras的一个错误。 If so, if there is a fix, how can I install this particular fix into Windows/Anaconda environment? 如果有,如果有修复,我该如何在Windows / Anaconda环境中安装此特定修补程序?

Keras version is 2.2.0 and tensorflow gpu 1.8.0 Keras版本是2.2.0和tensorflow gpu 1.8.0

Any idea? 任何的想法?

Thanks in advance to everyone. 在此先感谢大家。

It seems to me that there is a tensorflow-gpu - keras version incompatibility in your machine. 在我看来,你的机器中存在tensorflow-gpu-keras版本不兼容。

Try keras 2.1.6 尝试keras 2.1.6

pip uninstall keras
pip install -I keras==2.1.6

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM