Export Gemma 2 from Keras to Saved Model?
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 928
- 派生
- 227
- PR 合并指标
- 30 天内没有已合并 PR
描述
Ok, downloaded Gemma2 from
https://www.kaggle.com/models/google/gemma-2/keras
-unpacked and got the following files:
/assets
config.json
metadata.json
model.weights.h5
tokenizer.json
-tried to load model by using following Python script:
import json
from tensorflow import keras
# 1. Path to the config and weights:
config_path = "d:/Install/TensorFlow/models/Gemma_2/config.json"
weights_path = "d:/Install/TensorFlow/models/Gemma_2/model.weights.h5"
saved_model_dir = "d:/Install/TensorFlow/models/Gemma_2/gemma2_saved_model"
# 2. load model configuration
with open(config_path, 'r') as f:
model_config = json.load(f)
# 3. Reconstruct the model:
model = keras.models.model_from_json(json.dumps(model_config))
# 4. Load the weights:
model.load_weights(weights_path)
# 5. Finally, save model as TensorFlow SavedModel format:
model.save(saved_model_dir, save_format="tf")
print("Model saved to the :", saved_model_dir)
-at the line
model = keras.models.model_from_json(json.dumps(model_config))
got following error:
ValueError: Unknown layer: GemmaBackbone. Please ensure this object is passed to the custom_objectsargument. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.
Questions:
- Can someone confirm that I'm on the right track?
- Looked at
- https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object
but not sure what to do with GemmaBackbone...huh?
any help?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Python 脚本开始,尤其检查在 GemmaBackbone 上失败的 model_from_json 调用,并查看下载的 config.json、model.weights.h5 和 tokenizer.json。确定此仓库是否支持将此 Gemma 2 软件包导出为 SavedModel;完成标准是记录受支持的工作流程,或明确说明不支持该功能。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- machine-learning
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100