import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
#模型
model = keras.Sequential()
# 1st Layer
model.add(layers.Conv2D(input_shape=(224,224,3),filters=64,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=64,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
# 2nd Layer
model.add(layers.Conv2D(filters=128,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=128,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
# 3rd Layer
model.add(layers.Conv2D(filters=256,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=256,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=256,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
# 4th Layer
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
# 5th Layer
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.Conv2D(filters=512,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
# Passing it to a Fully Connected layer
model.add(layers.Flatten())
# 7th Fully Connected Layer
model.add(layers.Dense(4096,activation='relu'))
model.add(layers.Dropout(0.5))
# 7th Fully Connected Layer
model.add(layers.Dense(4096,activation='relu'))
model.add(layers.Dropout(0.5))
# Output Layer
model.add(layers.Dense(1000,activation='softmax'))
model.summary()
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_31 (Conv2D) (None, 224, 224, 64) 1792
_________________________________________________________________
conv2d_32 (Conv2D) (None, 224, 224, 64) 36928
_________________________________________________________________
max_pooling2d_13 (MaxPooling (None, 112, 112, 64) 0
_________________________________________________________________
conv2d_33 (Conv2D) (None, 112, 112, 128) 73856
_________________________________________________________________
conv2d_34 (Conv2D) (None, 112, 112, 128) 147584
_________________________________________________________________
max_pooling2d_14 (MaxPooling (None, 56, 56, 128) 0
_________________________________________________________________
conv2d_35 (Conv2D) (None, 56, 56, 256) 295168
_________________________________________________________________
conv2d_36 (Conv2D) (None, 56, 56, 256) 590080
_________________________________________________________________
conv2d_37 (Conv2D) (None, 56, 56, 256) 590080
_________________________________________________________________
max_pooling2d_15 (MaxPooling (None, 28, 28, 256) 0
_________________________________________________________________
conv2d_38 (Conv2D) (None, 28, 28, 512) 1180160
_________________________________________________________________
conv2d_39 (Conv2D) (None, 28, 28, 512) 2359808
_________________________________________________________________
conv2d_40 (Conv2D) (None, 28, 28, 512) 2359808
_________________________________________________________________
max_pooling2d_16 (MaxPooling (None, 14, 14, 512) 0
_________________________________________________________________
conv2d_41 (Conv2D) (None, 14, 14, 512) 2359808
_________________________________________________________________
conv2d_42 (Conv2D) (None, 14, 14, 512) 2359808
_________________________________________________________________
conv2d_43 (Conv2D) (None, 14, 14, 512) 2359808
_________________________________________________________________
max_pooling2d_17 (MaxPooling (None, 7, 7, 512) 0
_________________________________________________________________
flatten_3 (Flatten) (None, 25088) 0
_________________________________________________________________
dense_11 (Dense) (None, 4096) 102764544
_________________________________________________________________
dropout_8 (Dropout) (None, 4096) 0
_________________________________________________________________
dense_12 (Dense) (None, 4096) 16781312
_________________________________________________________________
dropout_9 (Dropout) (None, 4096) 0
_________________________________________________________________
dense_13 (Dense) (None, 1000) 4097000
=================================================================
Total params: 138,357,544
Trainable params: 138,357,544
Non-trainable params: 0
_________________________________________________________________
版权声明:原创,转载请注明来源,否则律师函警告
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!