【发布时间】:2019-05-07 12:33:31
【问题描述】:
所以我正在构建一个神经网络,它将接收 2 个输入(图像)并返回一个二进制输出(0 或 1)。
我已经有了我的标签和输入。
标签和输入的形状如下:
--------Labels--------
(8281,)
--------Images--------
(8281, 500, 500, 1)
这是我的代码:
input_front_images1 = Input(shape=(500, 500, 1))
input_front_images2 = Input(shape=(500, 500, 1))
x1=Conv2D(32, kernel_size=3,activation='relu')(input_front_images1)
x2=Conv2D(32, kernel_size=3,activation='relu')(input_front_images2)
x = keras.layers.concatenate([x1, x2])
x = Dense(64, activation='relu')(x)
predictions = Dense(1, activation='sigmoid')(x)
model = Model(inputs=[input_front_images1,input_front_images2],
outputs=predictions)
model.compile( optimizer= 'rmsprop' , loss='categorical_crossentropy' ,
metrics=['accuracy'])
model.summary()
model.fit([image_front_pairs1,image_front_pairs2],
[labels_front_pairs],epochs=2,batch_size=64)
它给了我这个错误:
ValueError: Error when checking target: expected dense_39 to have 4 dimensions, but got array with shape (8281, 1)
【问题讨论】:
标签: python keras neural-network keras-layer