我对喀拉喀什串联有一些三维问题。似乎模型的输出数组(无,851)与错误消息中要求的尺寸不同。这是我得到的:
input_img = Input(shape=(32, 100, 1))
conv1 = Conv2D(filters = 64, kernel_size=(5, 5), strides=1, padding="same", activation="relu")(input_img)
maxpool1 = MaxPooling2D(pool_size=(2, 2), strides=None, padding='valid', data_format=None)(conv1)
conv2 = Conv2D(filters = 128, kernel_size=(5, 5), strides=1, padding="same", activation="relu")(maxpool1)
maxpool2 = MaxPooling2D(pool_size=(2, 2), strides=None, padding='valid', data_format=None)(conv2)
conv3 = Conv2D(filters = 256, kernel_size=(3, 3), strides=1, padding="same", activation="relu")(maxpool2)
maxpool3 = MaxPooling2D(pool_size=(2, 2), strides=None, padding='valid', data_format=None)(conv3)
conv4 = Conv2D(filters = 512, kernel_size=(3, 3), strides=1, padding="same", activation="relu")(maxpool3)
conv5 = Conv2D(filters = 512, kernel_size=(3, 3), strides=1, padding="same", activation="relu")(conv4)
flat1 = Flatten(data_format=None)(conv5)
dense1 = Dense(units = 4096, activation = "relu")(flat1)
dense2 = Dense(units = 4096)(dense1)
towers = [Dense(units = 37, activation='softmax')(dense2) for i in range (23)]
output = concatenate(towers, axis = -1)
char = Model(input=input_img, output=output)
当我尝试拟合模型时,收到以下消息: ValueError:检查目标时出错:预期concatenate_1具有形状(1,)但形状为数组(851,)
我不明白为什么concatenate_1应该具有形状(1,)而不是(851,)或(None,851) 我的target_train的大小为(867,851),因此。
有人遇到过这种错误吗?
非常感谢您
答案 0 :(得分:0)
问题出在您的target_train
,这是您打算学习的理想输出。网络在串联之后是23 * 37-> 851,其摘要中为(None, 851)
,其中None
是动态批次大小。
您需要研究如何将target_train
传递给.fit
函数。该模型的输出为851,但训练循环将给出1个单个目标。