我见过其他问题,这些问题与我的相似,但没有一个问题解决了我的问题。我正在建立一个神经网络,该神经网络在训练过程中会反复获取256张大小为(600,600,2)的图像,但是我不断收到错误消息:
ValueError: Error when checking target: expected dense_2 to have 2 dimensions, but got array with shape (256, 1, 5)
这是模型架构:
self.policy_model = Sequential()
self.policy_model.add(Conv2D(32, (5, 5), padding = 'same', activation = 'relu', data_format = "channels_last", input_shape = (600, 600, 2)))
self.policy_model.add(Conv2D(64, (5, 5), padding="same", activation="relu"))
self.policy_model.add(Conv2D(96, (5, 5), padding="same", activation="relu"))
self.policy_model.add(Flatten())
self.policy_model.add(Dense(16, activation = "relu"))
self.policy_model.add(Dense(5, activation = "softmax"))
self.policy_model.compile(optimizer = 'rmsprop', loss = 'mean_squared_error')