为什么我的NASNet模型的准确性在训练期间没有提高?

时间:2020-06-18 23:49:55

标签: python tensorflow machine-learning keras deep-learning

我已经在keras中定制了以下模型,但是,当我训练时,该模型的准确性几乎没有提高:

from keras.applications.nasnet import NASNetLarge
from keras.optimizers import SGD

base_model = NASNetLarge(weights='imagenet', include_top=True)

x = base_model.layers[-6].output
x = Flatten(name='FLATTEN')(x)
x = Dense(256, activation='relu', name='last_FC1')(x)  # let's add a fully-connected layer
x = Dropout(0.5, name='DROPOUT')(x) # Dropout layer so the visualisations are done properly
predictions = Dense(len(classes), activation='softmax', name='PREDICTIONS')(x)
model = Model(input=base_model.input, outputs=predictions)

for layer in model.layers[:-290]:
    layer.trainable = False

model.compile(optimizer=SGD(lr=0.0001, momentum=0.9),
                  loss='categorical_crossentropy',
                  metrics=['accuracy'])
model.summary()

仅供参考,训练准确性,训练损失,验证准确性和验证损失如下:

时代|精度|损失val_accuracy | val_loss

0 | 0.5149105 | 60.32275529 | 0.463636369 | 0.693147182

1 | 0.51292247 | 0.693200452 | 0.53694582 | 0.695120037

2 | 0.528827 | 0.692723821 | 0.532019675 | 0.689894736

3 | 0.53677934 | 0.692179034 | 0.551724136 | 0.695185542

4 | 0.53479123 | 0.69184255 | 0.453201979 | 0.696151495

5 | 0.54075545 | 0.69120561 | 0.571428597 | 0.693781257

6 | 0.5149105 | 0.69272005 | 0.541871905 | 0.70132494

7 | 0.528827 | 0.69375147 | 0.566502452 | 0.693984807

有人可以建议我在上述代码中更改哪些变量以改善培训吗?

如何知道在Keras模型中要修改哪些变量以改善模型的训练?

0 个答案:

没有答案