Python 3.x 层上的不兼容值错误应为ndim=4,发现ndim=5
我正在使用更快的RCNN实现对象检测 获取错误:Python 3.x 层上的不兼容值错误应为ndim=4,发现ndim=5,python-3.x,tensorflow,keras,Python 3.x,Tensorflow,Keras,我正在使用更快的RCNN实现对象检测 获取错误: ValueError: Input 0 is incompatible with layer res5a_branch2a: expected ndim=4, found ndim=5 用于以下网络设计 num_rois=4 roi_input = Input(shape=(num_rois, 4)) out_roi_pool = RoiPoolingConv(14, 3)([model2.output, roi_input]) ROIPo
ValueError: Input 0 is incompatible with layer res5a_branch2a: expected ndim=4, found ndim=5
用于以下网络设计
num_rois=4
roi_input = Input(shape=(num_rois, 4))
out_roi_pool = RoiPoolingConv(14, 3)([model2.output, roi_input])
ROIPoolgconv是用户定义的函数和out_roi_池的输出
<tf.Tensor 'roi_pooling_conv_49/transpose:0' shape=(1, 3, 14, 14, 2048)
dtype=float32>
pooling_regions = 14 #Size of pooling region
num_rois=4 #number of regions of interest
input_shape = (num_rois,14,14,1024)
nb_filter1, nb_filter2, nb_filter3 = [512,512,2048]
old_layer = TimeDistributed(Convolution2D(nb_filter1, (1, 1), strides=(1,1),
trainable=False, kernel_initializer='normal'),input_shape=out_roi_pool.shape, name='2b')(out_roi_pool )
池区=14池区大小
num_rois=4#感兴趣区域的数量
输入形状=(ROI数量,14,141024)
nb_过滤器1、nb_过滤器2、nb_过滤器3=[512512248]
旧层=时间分布(卷积2D(nb_过滤器1,(1,1),步幅=(1,1),
trainable=False,kernel\u initializer='normal'),input\u shape=out\u roi\u pool.shape,name='2b')(out\u roi\u pool)
已引用,但仍无法解决错误
非常感谢任何潜在客户 为可能或将陷入维度不匹配错误的人发布解决错误的答案
num_rois=4
roi_input = Input(shape=(num_rois, 4))
out_roi_pool = RoiPoolingConv(14, 3)([model2.output, roi_input])
ROIPoolgconv是用户定义的函数,可重新定义out_roi_池的输出
现在输出将是
<tf.Tensor 'roi_pooling_conv_49/transpose:0' shape=(1, 3, 14, 14,1024) dtype=float32>
pooling_regions = 14 #Size of pooling region
num_rois=4 #number of regions of interest
input_shape = (num_rois,14,14,1024)
nb_filter1, nb_filter2, nb_filter3 = [512,512,1024]
old_layer = TimeDistributed(Convolution2D(nb_filter1, (1, 1), strides=(1,1),
trainable=False,
kernel_initializer='normal'),input_shape=out_roi_pool.shape, name='2b')
(out_roi_pool )
池区=14池区大小
num_rois=4#感兴趣区域的数量
输入形状=(ROI数量,14,141024)
nb_过滤器1、nb_过滤器2、nb_过滤器3=[512512124]
旧层=时间分布(卷积2D(nb_过滤器1,(1,1),步幅=(1,1),
可训练=错误,
kernel\u initializer='normal'),input\u shape=out\u roi\u pool.shape,name='2b')
(外池)
这解决了我的错误您可以在基本模型的末尾添加密集层 i、 e.模型2.直接提供给GCONV函数之前的输出
x = Dense(1024, name='avg_pool')(model2.layers[-1].output)
in_img = model2.input
new_model = Model(input=in_img, output=[x])
new_model.summary()
out_roi_pool = RoiPoolingConv(14, 3)([new_model.output, roi_input])
或者,您已经建立了模型,并相应地输入了形状