重塑层,但不会重塑

时间:2018-06-03 01:39:01

标签: python tensorflow keras

大家好,同时添加一个简单而琐碎的 Keras Reshape图层来重塑我的卷积中的图像

    decoder = BatchNormalization()(decoder)
    decoder = Reshape((224 * 512, n_classes), input_shape=(224, 512, 3))(decoder)

    predictions = Activation('softmax')(decoder)

运行时出现此错误

ValueError: Error when checking target: expected activation_13 to have 3 dimensions, but got array with shape (8, 224, 512, 3)

奇怪的是,它出现在图表中:

batch_normalization_13 (Batc (None, 224, 512, 3)       12
_________________________________________________________________
reshape_1 (Reshape)          (None, 114688, 3)         0
_________________________________________________________________
activation_13 (Activation)   (None, 114688, 3)         0
______________________________________________________________

1 个答案:

答案 0 :(得分:0)

这是预期的行为,错误是抱怨批量大小,因此您的最终输出是3维,如摘要中所示。问题是你的目标,火车没有重新塑造。您需要重塑目标数组,传递的数组适合形状(samples, 114688, 3)的3D张量。