VGG-16 (Visual Geometry Group - 16 layers)
숫자에 따라 layer가 달라진다(VGG-19, VGG-13)
논문 : https://arxiv.org/abs/1409.1556
# 하드 코딩
def VGG_16(input_shape):
initializer = tf.keras.initializers.GlorotNormal()
model = Sequential(name='VGG')
model.add(Conv2D(64, kernel_size=(3,3), padding= 'same', activation= 'relu', input_shape= input_shape))
model.add(Conv2D(64, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides= (2,2)))
model.add(Conv2D(128, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(128, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides= (2,2)))
model.add(Conv2D(256, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(256, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(256, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides= (2,2)))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides= (2,2)))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(Conv2D(512, kernel_size=(3,3), padding= 'same', activation= 'relu'))
model.add(MaxPooling2D(pool_size=(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'))
return model
# 사전 학습된 모델 불러오기
from tensorflow.python.keras.applications.vgg16 import VGG16
input_tensor = Input(shape=(224,224,3))
model = VGG16(weights='imagenet', # imagenet으로 사전 학습된 가중치
include_top=False, # 신경망 FCL X
input_tensor = input_tensor)