frcnn ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1_4/Reshape_4' (op: 'Reshape') with
在运行Faster-Rcnn时出现了这样的问题,参考了这位大神的文章,链接附上:
大神文章
在调用faster RCnn 时shared_layers = nn.nn_base(img_input, trainable=True) ,报错:
InvalidArgumentError: Shape must be rank 1 but is rank 0 for ‘bn_conv1_1/Reshape_4’ (op: ‘Reshape’) with input shapes: [1,1,1,64], [].
经过查阅,发现是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.6:
pip3 uninstall keras
pip3 install keras==2.1.6 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
成功运行啦!