卷积层的维度变化
import keras from keras import Sequential model = Sequential() model.add(keras.layers.Conv2D(input_shape=(28, 28, 1), kernel_size=(5,5), filters=20, activation='relu')) model.add(keras.layers.MaxPool2D(pool_size=(2,2), strides=2, padding='same')) model.add(keras.layers.Conv2D(kernel_size=(5,5), filters=50, activation='relu', padding='same')) model.add(keras.layers.MaxPool2D(pool_size=(2,2), strides=2, padding='same')) model.add(keras.layers.Flatten()) model.add(keras.layers.Dense(500, activation='relu')) model.add(keras.layers.Dense(10, activation='softmax')) ##>>> model.layers[0].output_shape ##(None, 24, 24, 20) ##>>> model.layers[1].output_shape ##(None, 12, 12, 20) ##>>> model.layers[2].output_shape ##(None, 12, 12, 50) ##>>> model.layers[3].output_shape ##(None, 6, 6, 50) ##>>> model.layers[4].output_shape ##(None, 1800) ##>>> model.layers[5].output_shape ##(None, 500) ##>>> model.layers[6].output_shape ##(None, 10)
//终于弄明白了。