Export Gemma 2 from Keras to Saved Model?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu với script Python, đặc biệt là lệnh gọi model_from_json bị lỗi trên GemmaBackbone, và xem xét các tệp config.json, model.weights.h5 và tokenizer.json đã tải xuống. Xác định xem repository này có hỗ trợ xuất gói Gemma 2 này sang SavedModel hay không; hoàn tất có nghĩa là ghi lại một quy trình được hỗ trợ hoặc giải thích rõ ràng rằng tính năng này không được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- Java
- Star
- 928
- Fork
- 227
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tensorflow/java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
tensorflow/java#653 · 1 bình luận · 4 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tensorflow/java#621 · 4 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tensorflow/java#617 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
tensorflow/java#615 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tensorflow/java#614 · 1 bình luận ·
Tất cả issue của tensorflow/java
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Đang mởbug frontend maui-pilot
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
objectionary/eo-graphs#74 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100