Export Gemma 2 from Keras to Saved Model?
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 928
- Fork
- 227
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dallo script Python, in particolare dalla chiamata model_from_json che fallisce su GemmaBackbone, e analizza config.json, model.weights.h5 e tokenizer.json scaricati. Determina se questo repository supporta l'esportazione di questo pacchetto Gemma 2 in SavedModel; il lavoro è completato quando documenti un flusso di lavoro supportato o spieghi chiaramente che non è supportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- machine-learning
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100