keras 에 클래식 네트워크 의 예비 훈련 모델(VGG 16 을 예 로 들 면)

1159 단어 keras
#   VGG16  
from keras.applications.vgg16 import VGG16
print('Start build VGG16 -------')

#   vgg16     ,       vgg16      :include_top=True
model_vgg16_conv = VGG16(weights='imagenet', include_top=False)
model_vgg16_conv.summary()

#          
# if K.image_data_format() == 'channels_first':
#   input_shape = (3, img_width, img_height)
# else:
#   input_shape = (img_width, img_height, 3)

input = Input(input_shape, name = 'image_input') #   ,Keras     Input 

#  vgg16              
output_vgg16_conv = model_vgg16_conv(input)

# output_vgg16_conv    vgg16    ,           ,             
x = Flatten(name='flatten')(output_vgg16_conv)
x = Dense(4096, activation='relu', name='fc1')(x)
x = Dense(512, activation='relu', name='fc2')(x)
x = Dense(128, activation='relu', name='fc3')(x)
x = Dense(1, activation='softmax', name='predictions')(x)

#         vgg16  
my_model = Model(input=input, output=x)

#         ,vgg16          ,               
print('
This is my vgg16 model for the task') my_model.summary()

좋은 웹페이지 즐겨찾기