出于某种原因,我为分类网络获得了一个未预期的输出维度。
网络有18个形状输入(45,5,3)
输出是一个长度为15的向量 - 每三分之一的一个类。提取的类来自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 of shape(16828,15),我得到一个值错误说明:
Error when checking model target: expected dense_3 to have 3 dimensions, but got array with shape (16828, 15)
为什么预计3昏暗而不是2昏暗?
模型摘要表明输出暗淡是(15,145),正如我所期望的那样?来自145个班级的15个班级。或者这是不正确的?
答案 0 :(得分:0)
如果我得到纠正,sum
为model.output_shape
,您在训练期间发送了一个形状为(None, 15, 145)
的数组。
您可能希望在适应之前将(16828, 15)
扩展为(16828, 15)
。