我正在尝试将扁平层作为 convd2d 的输入,并使用 cifar-10 数据集预测 Densenet 上 10 类分类问题的输出。以下代码片段出现错误。
global compression
BatchNorm = layers.BatchNormalization()(input)
relu = layers.Activation('relu')(BatchNorm)
AvgPooling = layers.AveragePooling2D(pool_size=(2,2))(relu)
flat = layers.Flatten()(AvgPooling)
# output = layers.Dense(num_classes, activation='softmax')(flat)
output = layers.Conv2D(filters=10,kernel_size=3,strides=1,activation='softmax',padding='valid')(flat)
我收到以下错误
ValueError: Input 0 is incompatible with layer conv2d_513: expected ndim=4, found ndim=2
谁能告诉我如何解决它。提前致谢。