码迷,mamicode.com
首页 > 其他好文 > 详细

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], [].

时间:2019-08-27 18:57:32      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:因此   png   value   nbsp   for   bat   net   enter   cond   

运行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

 

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], [].

标签:因此   png   value   nbsp   for   bat   net   enter   cond   

原文地址:https://www.cnblogs.com/wind-chaser/p/11420032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!