为什么我的以下经过修改的vgg-16 Keras模型需要1小时才能运行一个纪元

时间:2018-11-16 16:14:00

标签: tensorflow keras keras-2 vgg-net

我的模特是

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
_________________________________________________________________

每个图像为128 * 128 * 3。我的笔记本电脑上有8个CPU,CPU使用率约为700%。为什么要花一个小时约1个小时?如何提高性能?谢谢

更新

下面是我的模型的详细信息:

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 个答案:

没有答案