ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/cond/Reshape_4' (op: 'Reshape') with input shapes: [1,64,1,1], [].


运行demo报错

ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/cond/Reshape_4' (op: 'Reshape') with input shapes: [1,64,1,1], [].

经过查阅,发现是BatchNormalization的问题,如下代码也会类似报错

from keras.layers import BatchNormalization, Input

 x = Input(shape=(1, 2, 2)) 

BatchNormalization(axis=1)(x)   

报错:InvalidArgumentError: Shape must be rank 1 but is rank 0 for 'batch_normalization_1/cond/Reshape_4' (op: 'Reshape') with input shapes: [1,1,1,1], [].

在CPU版的keras 2.2.0上没有问题,在gup版本的keras有问题。因此将keras 降低版本为2.1.2:

 pip3 uninstall keras

 pip3 install keras==2.1.2  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

ref:https://blog.csdn.net/weixin_40755306/article/details/84944008

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM