【问题标题】:Validation Accuracy remains constant while training VGG训练 VGG 时验证准确度保持不变
【发布时间】:2021-03-06 07:48:24
【问题描述】:

这是剧情

这是代码:

with strategy.scope():

  model2 = tf.keras.applications.VGG16(
    include_top=True,
    weights=None,
    input_tensor=None,
    input_shape=(32, 32, 3),
    pooling=None,
    classes=10,
    classifier_activation="relu",
  )

  model2.compile(optimizer='adam',
                loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
                metrics=['accuracy'])
  
  history = model2.fit(
            train_images, train_labels,epochs=10, 
            validation_data=(test_images, test_labels)
            )

我正在尝试从头开始训练 VGG16,因此不导入它们的权重(因此 weights=None) 我还尝试了一个我自己创建的模型,具有相同的超参数,效果很好。

这里可能有什么问题?

非常感谢任何帮助

Heres完整代码

【问题讨论】:

    标签: deep-learning tensor


    【解决方案1】:

    好的,我解决了这个问题 简单的事情是学习率太大了 我把代码改成了这个

    LR = batch_size/((z+1)*100000)
    LR=LR/3
    

    而不是

    LR = batch_size/((z+1)*1000)
    LR=LR/3
    

    它似乎运作良好

    【讨论】:

    • 问题仍然存在,为什么它在训练的情况下表现出不错的准确性,而当学习率太高时却没有在验证中表现出来
    猜你喜欢
    • 2019-01-30
    • 2018-12-20
    • 2017-07-19
    • 1970-01-01
    • 2021-07-22
    • 2020-07-08
    • 2020-10-25
    • 2020-03-29
    • 1970-01-01
    相关资源
    最近更新 更多