1
由於某種原因,我獲得了我的分類網絡的預期輸出尺寸。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個班。或者這是不正確的?
模型彙總: https://pastebin.com/27YTQW2m
'print merge.shape'的結果是什麼? – Van
@Van(?,15,1,324) –
你的輸出數組存儲了什麼?整型?你的'損失'功能是什麼? –