【问题标题】:How to fine tune a trained model and saved model with tensorflow?如何使用 tensorflow 微调训练好的模型和保存的模型?
【发布时间】:2021-10-06 14:20:08
【问题描述】:

我有一个大数据集,我想通过这个数据集训练efficientnetb0,但是 google colab 运行超时,所以我想训练模型的全连接层并保存它,然后在几个小时后再次加载并进行微调基本模型(efficientnetb0)。我该怎么做?

【问题讨论】:

    标签: tensorflow deep-learning transfer-learning efficientnet


    【解决方案1】:

    您可以通过以下方式执行此操作。请根据您的要求进行更改。这是起点的快照。

    if not os.path.exists('e10.h5'):
        model = get_model() #this method constructs the model and compiles it 
    else:
        model = load_model('tf_keras_cifar10.h5') #load the model from file
        print('lr is ', K.get_session().run(model.optimizer.lr))
        initial_epoch=10
        epochs=13
    
    history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs,validation_data=(x_test, y_test), initial_epoch=initial_epoch)
    model.save('e.h5')
    

    【讨论】:

    • 感谢您的回答。此代码训练整个模型。我想微调我用作自己模型的基本模型的efficientnetb0。换句话说,我想训练模型的某些层。
    猜你喜欢
    • 1970-01-01
    • 2021-11-24
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多