我想像这个图像一样可视化keras模型的中间层 .
enter image description here

我在 github.com/EN10/KerasMNIST 中使用了CNN model,它已经有一个预先训练过的模型 . 而模型看起来像这样

Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 26, 26, 32)        320       
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 24, 24, 64)        18496     
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 64)        0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 12, 12, 64)        0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 9216)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 128)               1179776   
_________________________________________________________________
dropout_2 (Dropout)          (None, 128)               0         
_________________________________________________________________
dense_2 (Dense)              (None, 10)                1290      
=================================================================
Total params: 1,199,882
Trainable params: 1,199,882
Non-trainable params: 0

我想要想象这个模型的第一个,第二个卷积和辍学层,并且根据this answer我只需要向我想要可视化的图层进行前向传递 . 问题是图像的维度为 28x28x1 ,而第一和第二卷积层维度分别为 26x26x3224x24x64 ,而丢失层为 12x12x64 . 如何将这些尺寸转换为图像尺寸,以便我们可以获得与上面相似的图像?