【发布时间】:2017-04-11 23:00:07
【问题描述】:
由于某种原因,我的分类网络得到了一个出乎意料的输出维度。
网络有 18 个形状为 (45,5,3) 的输入
输出是一个长度为 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)
但由于某种原因,当我传递输出数据时出现错误。 它当前存储为形状 (16828,15) 的 numpy.ndarray,我收到一个值错误说明:
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 个班级。或者这是不正确的?
【问题讨论】:
-
print merge.shape的结果是什么? -
@Van (?, 15, 1, 324)
-
你的输出数组存储的是什么?整数?你的
loss功能是什么? -
还没有决定关于损失的任何事情......所以将尝试使用 SGD,从那里看到......但是带有类的向量。