从keras看VGG16结构图
"""
Created on Thu Jul 5 14:50:29 2018
@author: brucelau
"""
from keras.models import Sequential
from keras.layers import Dense, Dropout,Flatten, ZeroPadding2D,Convolution2D,MaxPooling2D
from keras import backend as K
K.set_image_dim_ordering('th')
model = Sequential()
model.add(ZeroPadding2D((1,1),input_shape=(3,224,224)))
model.add(Convolution2D(64, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(64, 3, 3, activation='relu'))
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(128, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(128, 3, 3, activation='relu'))
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(256, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(256, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(256, 3, 3, activation='relu'))
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(ZeroPadding2D((1,1)))
model.add(Convolution2D(512, 3, 3, activation='relu'))
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(Flatten())
model.add(Dense(4096, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(4096, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1000, activation='softmax'))
model.summary()
_________________________________________________________________
zero_padding2d_1 (ZeroPaddin (None, 3, 226, 226) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 64, 224, 224) 1792
_________________________________________________________________
zero_padding2d_2 (ZeroPaddin (None, 64, 226, 226) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 64, 224, 224) 36928
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 64, 112, 112) 0
_________________________________________________________________
zero_padding2d_3 (ZeroPaddin (None, 64, 114, 114) 0
_________________________________________________________________
conv2d_3 (Conv2D) (None, 128, 112, 112) 73856
_________________________________________________________________
zero_padding2d_4 (ZeroPaddin (None, 128, 114, 114) 0
_________________________________________________________________
conv2d_4 (Conv2D) (None, 128, 112, 112) 147584
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 128, 56, 56) 0
_________________________________________________________________
zero_padding2d_5 (ZeroPaddin (None, 128, 58, 58) 0
_________________________________________________________________
conv2d_5 (Conv2D) (None, 256, 56, 56) 295168
_________________________________________________________________
zero_padding2d_6 (ZeroPaddin (None, 256, 58, 58) 0
_________________________________________________________________
conv2d_6 (Conv2D) (None, 256, 56, 56) 590080
_________________________________________________________________
zero_padding2d_7 (ZeroPaddin (None, 256, 58, 58) 0
_________________________________________________________________
conv2d_7 (Conv2D) (None, 256, 56, 56) 590080
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 256, 28, 28) 0
_________________________________________________________________
zero_padding2d_8 (ZeroPaddin (None, 256, 30, 30) 0
_________________________________________________________________
conv2d_8 (Conv2D) (None, 512, 28, 28) 1180160
_________________________________________________________________
zero_padding2d_9 (ZeroPaddin (None, 512, 30, 30) 0
_________________________________________________________________
conv2d_9 (Conv2D) (None, 512, 28, 28) 2359808
_________________________________________________________________
zero_padding2d_10 (ZeroPaddi (None, 512, 30, 30) 0
_________________________________________________________________
conv2d_10 (Conv2D) (None, 512, 28, 28) 2359808
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 512, 14, 14) 0
_________________________________________________________________
zero_padding2d_11 (ZeroPaddi (None, 512, 16, 16) 0
_________________________________________________________________
conv2d_11 (Conv2D) (None, 512, 14, 14) 2359808
_________________________________________________________________
zero_padding2d_12 (ZeroPaddi (None, 512, 16, 16) 0
_________________________________________________________________
conv2d_12 (Conv2D) (None, 512, 14, 14) 2359808
_________________________________________________________________
zero_padding2d_13 (ZeroPaddi (None, 512, 16, 16) 0
_________________________________________________________________
conv2d_13 (Conv2D) (None, 512, 14, 14) 2359808
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 512, 7, 7) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 25088) 0
_________________________________________________________________
dense_1 (Dense) (None, 4096) 102764544
_________________________________________________________________
dropout_1 (Dropout) (None, 4096) 0
_________________________________________________________________
dense_2 (Dense) (None, 4096) 16781312
_________________________________________________________________
dropout_2 (Dropout) (None, 4096) 0
_________________________________________________________________
Total params: 138,357,544
Trainable params: 138,357,544
Non-trainable params: 0
_________________________________________________________________