tensorflow - 如何使用 tensorflow 微调训练好的模型和保存的模型?
问题描述
我有一个大数据集,我想通过这个数据集训练efficientnetb0,但是 google colab 运行超时,所以我想训练模型的完全连接层并保存它,然后在几个小时后再次加载并微调基本模型(高效网络b0)。我怎样才能做到这一点?
解决方案
您可以通过以下方式执行此操作。请根据您的要求进行更改。这是起点的快照。
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')
推荐阅读
- html - 我的选择标签的宽度不想改变
- dll - 如何将注入的DLL的远程Proc地址获取到另一个进程中
- swift - 在用户购买之前锁定游戏的特定部分
- delphi - 如何让透明图像出现在 TMenu 项目上
- smalltalk - Windows 上 Smalltalk (Pharo) 中的标准输入
- snakemake - 使用 snakemake 的 MissingOutputException 和延迟等待错误
- android - 如何在 Mac OS 上安装 ANDROID_SDK_ROOT?
- python - IndexError:列表索引超出范围。任何人都可以帮我解决这个 Python 代码吗?包括 numpy 和 pandas 的概念
- javascript - 正则表达式匹配两个单词之间的字符串,其中结束边界词是可选的
- vba - MS Access:如何通过 SQL 或 VBA 返回该表中具有“超链接”字段格式的所有表和字段名称?