代码之家  ›  专栏  ›  技术社区  ›  BAE

为什么我下面修改的vgg-16 Keras模型运行一个时代需要1个小时

  •  0
  • BAE  · 技术社区  · 5 年前

    我的模型是

    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 回复  |  直到 5 年前
    推荐文章