keras cnn网络中的预期输出尺寸
问题描述:
由于某种原因,我获得了我的分类网络的预期输出尺寸。keras cnn网络中的预期输出尺寸
该网络具有形状(45,5,3)
的18级的输入和输出是长度为15的矢量 - 每个第三45.萃取类一个类来自145类的池。
我的网络是这样的:
#stride = 2
#dim = 40
#window_height = 5
#splits = ((40-5)+1)/2 = 18
kernel_number = int(math.ceil(splits))
list_of_input = [Input(shape = (45,5,3)) for i in range(splits)]
list_of_conv_output = []
list_of_max_out = []
for i in range(splits):
list_of_conv_output.append(Conv2D(filters = kernel_number , kernel_size = (int(splits-3),3))(list_of_input[i]))
list_of_max_out.append((MaxPooling2D(pool_size=((2,2)))(list_of_conv_output[i])))
merge = keras.layers.concatenate(list_of_max_out)
print merge.shape
reshape = Reshape((15,324))(merge)
dense1 = Dense(units = 1000, activation = 'relu', name = "dense_1")(reshape)
dense2 = Dense(units = 1000, activation = 'relu', name = "dense_2")(dense1)
dense3 = Dense(units = 145 , activation = 'softmax', name = "dense_3")(dense2)
model = Model(inputs = list_of_input ,outputs = dense3)
但由于某种原因,我会得到一个错误,当我通过我的输出数据。 这是目前存储为numpy.ndarray形状(16828,15)和我得到一个值错误,指出:
Error when checking model target: expected dense_3 to have 3 dimensions, but got array with shape (16828, 15)
为什么预期的3暗淡,而不是2暗淡?
模型总结表明,输出dim是(15,145),我也会期待?来自145个班级的15个班。或者这是不正确的?
答
如果我纠正,model.output_shape
是(None, 15, 145)
和训练时发出的数组形状(16828, 15)
。
在安装之前,您可能需要将(16828, 15)
扩展为(16828, 15, 145)
。
'print merge.shape'的结果是什么? – Van
@Van(?,15,1,324) –
你的输出数组存储了什么?整型?你的'损失'功能是什么? –