-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvgg16first.py
33 lines (26 loc) · 1.03 KB
/
vgg16first.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from keras.applications import VGG16
# VGG16 was designed to work on 224 x 224 pixel input images sizes
img_rows = 224
img_cols = 224
#Loads the VGG16 model
model = VGG16(weights = 'imagenet',
include_top = False,
input_shape = (img_rows, img_cols, 3))
# Let's print our layers
for (i,layer) in enumerate(model.layers):
print(str(i) + " "+ layer.__class__.__name__, layer.trainable)
from keras.applications import VGG16
# VGG16 was designed to work on 224 x 224 pixel input images sizes
img_rows = 224
img_cols = 224
# Re-loads the VGG16 model without the top or FC layers
model = VGG16(weights = 'imagenet',
include_top = False,
input_shape = (img_rows, img_cols, 3))
# Here we freeze the last 4 layers
# Layers are set to trainable as True by default
for layer in model.layers:
layer.trainable = False
# Let's print our layers
for (i,layer) in enumerate(model.layers):
print(str(i) + " "+ layer.__class__.__name__, layer.trainable)