import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
#模型
model = keras.Sequential()

# 1st Convolutional Layer
model.add(layers.Conv2D(input_shape=(227,227,3),filters=96,kernel_size=[11,11],strides=(4,4),padding='valid',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='valid'))

# 2nd Convolutional Layer
model.add(layers.Conv2D(filters=256,kernel_size=[5,5],strides=(1,1),padding='same',activation='relu'))
model.add(layers.MaxPool2D(pool_size=(3,3),strides=(2,2),padding='valid'))

# 3rd Convolutional Layer
model.add(layers.Conv2D(filters=384,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))

# 4th Convolutional Layer
model.add(layers.Conv2D(filters=384,kernel_size=[3,3],strides=(1,1),padding='same',activation='relu'))

# 5th Convolutional Layer
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='valid'))

# Passing it to a Fully Connected layer
model.add(layers.Flatten())

# 6th 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_25 (Conv2D)           (None, 55, 55, 96)        34944     
_________________________________________________________________
max_pooling2d_13 (MaxPooling (None, 27, 27, 96)        0         
_________________________________________________________________
conv2d_26 (Conv2D)           (None, 27, 27, 256)       614656    
_________________________________________________________________
max_pooling2d_14 (MaxPooling (None, 13, 13, 256)       0         
_________________________________________________________________
conv2d_27 (Conv2D)           (None, 13, 13, 384)       885120    
_________________________________________________________________
conv2d_28 (Conv2D)           (None, 13, 13, 384)       1327488   
_________________________________________________________________
conv2d_29 (Conv2D)           (None, 13, 13, 256)       884992    
_________________________________________________________________
max_pooling2d_15 (MaxPooling (None, 6, 6, 256)         0         
_________________________________________________________________
flatten_3 (Flatten)          (None, 9216)              0         
_________________________________________________________________
dense_12 (Dense)             (None, 4096)              37752832  
_________________________________________________________________
dropout_9 (Dropout)          (None, 4096)              0         
_________________________________________________________________
dense_13 (Dense)             (None, 4096)              16781312  
_________________________________________________________________
dropout_10 (Dropout)         (None, 4096)              0         
_________________________________________________________________
dense_14 (Dense)             (None, 1000)              4097000   
_________________________________________________________________
dropout_11 (Dropout)         (None, 1000)              0         
_________________________________________________________________
dense_15 (Dense)             (None, 1000)              1001000   
=================================================================
Total params: 63,379,344
Trainable params: 63,379,344
Non-trainable params: 0
_________________________________________________________________

版权声明:原创,转载请注明来源,否则律师函警告



深度学习      神经网络模型

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!