我建立了一个CNN模型,尺寸方面遇到了麻烦。
src = Input(shape=(196,41,3))
conv11 = Conv2D(32, kernel_size=4, activation='relu')(src)
pool11 = MaxPooling2D(pool_size=(2, 2))(conv11)
conv12 = Conv2D(16, kernel_size=4, activation='relu')(pool11)
drop = Dropout(0.3)
pool12 = MaxPooling2D(pool_size=(2, 2))(conv12)
flat1 = Flatten()(pool12)
# second input model
trgt = Input(shape=(196,41,3))
conv21 = Conv2D(32, kernel_size=4, activation='relu')(trgt)
pool21 = MaxPooling2D(pool_size=(2, 2))(conv21)
conv22 = Conv2D(16, kernel_size=4, activation='relu')(pool21)
pool22 = MaxPooling2D(pool_size=(2, 2))(conv22)
flat2 = Flatten()(pool22)
# merge input models
merge = keras.layers.concatenate([flat1, flat2])
# interpretation model
hidden1 = Dense(64, activation='relu')(merge)
output = Dense(196, activation='relu')(hidden1)
arch = Model(inputs=[src, trgt], outputs=output)
我明白了
检查目标时出错:预期density_35具有2维,但数组的形状为(70,41,196,3)