迁移学习 ValueError: Input 0 of layer global_average_pooling2d is incompatible with the layer: expected ndim=4, found ndim=2. Full shape received: [None, 1000]: 问题描述: include_top要为False x2 = ResNet50(include_top=False, weights='imagenet', input_tensor=input_rgb) for layer in x2.layers: layer.trainable = False x2 = x2.output x2 = Flatten()(x2) x2 = Dense(512, activation='relu')(x2) x2 = Dropout(0.5)(x2) x2 = Dense(128, activation='relu')(x2) x2 = Dropout(0.5)(x2) x2 = Dense(64, activation='relu')(x2) x_2 = Model(inputs=input_rgb, outputs=x2)