tensorflow - 如何使用tfhub提供的efficientnet-lite进行tf2.1的二次训练
问题描述
我使用的版本是 tensorflow-gpu 2.1.0 版,从 pip 安装。
import tensorflow as tf
import tensorflow_hub as hub
tf.keras.backend.set_learning_phase(True)
module_url = "https://tfhub.dev/tensorflow/efficientnet/lite0/classification/2"
module2 = tf.keras.Sequential([
hub.KerasLayer(module_url, trainable=False, input_shape=(224,224,3))])
output1 = module2(tf.ones(shape=(1,224,224,3)))
print(module2.summary())
当我设置trainable = True
时,操作会报错。那么,我不能在 tf2.1 版本上重新训练它吗?
解决方案
TFHub 上的 EfficientNet-Lite 模型基于 TensorFlow 1,因此受到 TF2 的许多限制,包括您发现的微调。EfficientNet 模型已更新到 TF2,但我们仍在等待它们的 lite 模型。
https://www.tensorflow.org/hub/model_compatibility
https://github.com/tensorflow/hub/issues/751
更新:从 2021 年 10 月 5 日开始,TFHub 上的 EfficientNet-Lite 模型可用于 TensorFlow 2。
推荐阅读
- algorithm - 比赛的获胜者
- ios - macOS Catalyst 应用程序未显示在 iTunes/App Store Connect 构建选项中
- javascript - 在回合制游戏中检测相邻玩家的有效方法
- javascript - JavaScript 表单验证无法使用 isNaN
- android - 没有收到来自 FCM 的任何通知
- javascript - JavaScript过滤器函数过滤掉数组中的零
- mysql - 跨多个表连接多个 SUM()
- java - 使用词干运算符的 AppEngine 全文文档索引搜索
- azure-machine-learning-service - 如何在 Azure 机器学习服务初始化期间传入模型名称?
- reactjs - 未捕获的错误:对象作为 React 子对象无效(找到:带有键 {$$typeof,render} 的对象)。我好像找不到问题?