我正在尝试在Keras中编写YOLOV1,我使用VGG16来接受(224,224,3),而输入为(448,448,3)(这是作者使用的大小),所以我添加了Conv2D和一个MaxPooling层将448转换为224。但是,当我使用plot_model时,位于中间的Conv和MaxPooling层的输入和输出形状都是问号(?)。
这是我的代码:
base_model = VGG16(
input_shape=backbone_img_shape,
# input_shape=img_shape,
include_top=False,
weights='imagenet')
# pdb.set_trace()
img_input = Input(shape=img_shape)
arch = layers.Conv2D(64, 3, padding='same', activation='relu') (img_input)
arch = layers.MaxPooling2D() (arch)
for i, layer in enumerate(base_model.layers[2:]):
arch = layer(arch)
# arch = base_model(img_input)
arch = layers.Flatten() (arch)
arch = layers.Dense(4096, activation='relu') (arch)
arch = layers.Dropout(0.5) (arch)
arch = layers.Dense((grid_num_per_axis**2)*(num_bbox_per_grid*5 + n_cls)) (arch)
arch = layers.Reshape(
(grid_num_per_axis, grid_num_per_axis, num_bbox_per_grid*5 + n_cls)) (arch)
model = Model(inputs=img_input, outputs=arch)
model.summary()
# pdb.set_trace()
model.compile(
# optimizer=SGD(lr=0.001, momentum=0.9),
optimizer='adam',
loss=yolov1_loss)
tf.keras.utils.plot_model(model, to_file='haha.png', show_shapes=True)
其中骨干_img_shape =(224,224,3)和img_shape =(448,448,3)。我认为这是有问题的,因为例如max_pooling2d层的大小为(?,224,224,64),但是后面的层应该有类似的东西,而不是(?)。请帮助我,非常感谢。