VGG16 ? ! . , , ImageNet, :
ImageNet - , . VGG16 3-4 . ( , GPU , NVIDIA GeForce Titan X), .
ImageNet . . , , ImageNet NBA.
VGG16. VGG16 , ( , , ):
, , . 5- ? ? , VGG? . , ; - SO .
VGG Keras
-:
ImageNet, VGG-16 VGG-19, Keras. VGG-16. Keras Applications.
from keras import applications
vgg_model = applications.VGG16(weights='imagenet', include_top=True)
vgg_model = applications.VGG16(weights='imagenet', include_top=False)
from keras.layers import Input
input_tensor = Input(shape=(160, 160, 3))
vgg_model = applications.VGG16(weights='imagenet',
include_top=False,
input_tensor=input_tensor)
vgg_model.summary()
, VGG
, (160, 160, 3) VGG, block2_pool.
vgg_model = applications.VGG16(weights='imagenet',
include_top=False,
input_shape=(160, 160, 3))
layer_dict = dict([(layer.name, layer) for layer in vgg_model.layers])
x = layer_dict['block2_pool'].output
x = Conv2D(filters=64, kernel_size=(3, 3), activation='relu')(x)
x = MaxPooling2D(pool_size=(2, 2))(x)
x = Flatten()(x)
x = Dense(256, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(10, activation='softmax')(x)
from keras.models import Model
custom_model = Model(input=vgg_model.input, output=x)
for layer in custom_model.layers[:7]:
layer.trainable = False
custom_model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
, VGG16, block1_conv1 block2_conv2 , .
, , . , :
vgg_model = applications.VGG16(include_top=True, weights='imagenet')
layers = [l for l in vgg_model.layers]
new_conv = Conv2D(filters=64,
kernel_size=(5, 5),
name='new_conv',
padding='same')(layers[0].output)
x = new_conv
for i in range(3, len(layers)):
layers[i].trainable = False
x = layers[i](x)
result_model = Model(input=layer[0].input, output=x)