why my below modified vgg-16 Keras model takes 1 hour to run one epoch

201 Views Asked by At

My model is

Using TensorFlow backend.
Found 8704 images belonging to 68 classes.
Found 2176 images belonging to 68 classes.
Found 1360 images belonging to 68 classes.

_________________________________________________________________
None
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
vgg16 (Model)                (None, 4, 4, 512)         14714688  
_________________________________________________________________
flatten_1 (Flatten)          (None, 8192)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 256)               2097408   
_________________________________________________________________
dropout_1 (Dropout)          (None, 256)               0         
_________________________________________________________________
dense_2 (Dense)              (None, 68)                17476     
=================================================================
Total params: 16,829,572
Trainable params: 3,850,372
Non-trainable params: 12,979,200
_________________________________________________________________

Each image is 128*128*3. There are 8 CPUs on my laptop and cpu usage is about 700%. why it takes about 1 hour to run one epoch? How to improve the performance? Thanks

UPDATE

Below is details of my model:

vgg16 = VGG16(include_top=False,
              weights='imagenet',
              input_tensor=None,
              input_shape=(IMG_SIZE, IMG_SIZE, CHANNELS),
              pooling=None,
              classes=68)


for layer in vgg16.layers[-8:-1]:
    layer.trainable = False

model = Sequential()

model.add(vgg16)
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(68, activation='softmax'))


print(model.summary())
0

There are 0 best solutions below