Export Gemma 2 from Keras to Saved Model?

オープン
#595 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python

調査の方向性

Python スクリプトから始め、特に GemmaBackbone で失敗する model_from_json 呼び出しを確認し、ダウンロードした config.json、model.weights.h5、tokenizer.json を調べてください。このリポジトリがこの Gemma 2 パッケージの SavedModel へのエクスポートをサポートしているか判断してください。対応しているワークフローを文書化するか、サポートされていないことを明確に説明できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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:

but not sure what to do with GemmaBackbone...huh?

any help?

主要言語
Java
スター
928
フォーク
227
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tensorflow/java のほかの issue

tensorflow/java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。