ภาพรวมไลบรารี TensorFlow Hub
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ไลบรารี tensorflow_hub
ให้คุณดาวน์โหลดและนำโมเดลที่ผ่านการฝึกอบรมกลับมาใช้ซ้ำในโปรแกรม TensorFlow ของคุณด้วยโค้ดขั้นต่ำ วิธีหลักในการโหลดโมเดลที่ผ่านการฝึกอบรมแล้วคือการใช้ hub.KerasLayer
API
import tensorflow_hub as hub
embed = hub.KerasLayer("https://tfhub.dev/google/nnlm-en-dim128/2")
embeddings = embed(["A long sentence.", "single-word", "http://example.com"])
print(embeddings.shape, embeddings.dtype)
หมายเหตุ: เอกสารนี้ใช้ตัวจัดการ URL ของ TFhub.dev ในตัวอย่าง ดูข้อมูลเพิ่มเติมเกี่ยวกับประเภทด้ามจับที่ถูกต้องอื่นๆ ที่นี่
การตั้งค่าตำแหน่งแคชสำหรับการดาวน์โหลด
ตามค่าเริ่มต้น tensorflow_hub
จะใช้ไดเร็กทอรีชั่วคราวทั้งระบบเพื่อแคชโมเดลที่ดาวน์โหลดและไม่มีการบีบอัด ดู การแคช สำหรับตัวเลือกในการใช้ตำแหน่งอื่นที่อาจถาวรมากกว่า
ความเสถียรของเอพีไอ
แม้ว่าเราหวังว่าจะป้องกันไม่ให้เกิดการเปลี่ยนแปลง แต่โปรเจ็กต์นี้ยังอยู่ระหว่างการพัฒนาและยังไม่รับประกันว่าจะมี API หรือรูปแบบโมเดลที่เสถียร
ความเป็นธรรม
เช่นเดียวกับ Machine Learning ทั้งหมด ความเป็นธรรม คือการพิจารณา ที่สำคัญ โมเดลที่ได้รับการฝึกล่วงหน้าหลายตัวได้รับการฝึกบนชุดข้อมูลขนาดใหญ่ เมื่อนำโมเดลใดๆ มาใช้ซ้ำ สิ่งสำคัญคือต้องคำนึงถึงข้อมูลที่โมเดลนั้นได้รับการฝึก (และมีความเอนเอียงใดๆ ที่มีอยู่หรือไม่) และสิ่งเหล่านี้อาจส่งผลต่อการใช้งานของคุณอย่างไร
ความปลอดภัย
เนื่องจากมีกราฟ TensorFlow ที่กำหนดเอง แบบจำลองจึงถือเป็นโปรแกรมได้ การใช้ TensorFlow อย่างปลอดภัย จะอธิบายผลกระทบด้านความปลอดภัยของการอ้างอิงโมเดลจากแหล่งที่ไม่น่าเชื่อถือ
ขั้นตอนต่อไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# TensorFlow Hub Library Overview\n\n\u003cbr /\u003e\n\nThe [`tensorflow_hub`](https://github.com/tensorflow/hub) library lets you\ndownload and reuse trained models in your TensorFlow program with a minimum\namount of code. The main way to load a trained model is using the\n[`hub.KerasLayer`](https://www.tensorflow.org/hub/api_docs/python/hub/KerasLayer) API. \n\n import tensorflow_hub as hub\n\n embed = hub.KerasLayer(\"https://tfhub.dev/google/nnlm-en-dim128/2\")\n embeddings = embed([\"A long sentence.\", \"single-word\", \"http://example.com\"])\n print(embeddings.shape, embeddings.dtype)\n\n**Note:** This documentation uses TFhub.dev URL handles in examples. See more\ninformation regarding other valid handle types [here](/hub/tf2_saved_model#model_handles).\n\nSetting the cache location for downloads.\n-----------------------------------------\n\nBy default, `tensorflow_hub` uses a system-wide, temporary directory to cache\ndownloaded and uncompressed models. See [Caching](/hub/caching) for options to use\nother, possibly more persistent locations.\n\nAPI stability\n-------------\n\nAlthough we hope to prevent breaking changes, this project is still under active\ndevelopment and is not yet guaranteed to have a stable API or model format.\n\nFairness\n--------\n\nAs in all of machine learning, [fairness](http://ml-fairness.com) is an\n[important](https://research.googleblog.com/2016/10/equality-of-opportunity-in-machine.html)\nconsideration. Many pre-trained models are trained on large datasets. When\nreusing any model, it's important to be mindful of what data the model was\ntrained on (and whether there are any existing biases there), and how these\nmight impact your use of it.\n\nSecurity\n--------\n\nSince they contain arbitrary TensorFlow graphs, models can be thought of as\nprograms.\n[Using TensorFlow Securely](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md)\ndescribes the security implications of referencing a model from an untrusted\nsource.\n\nNext Steps\n----------\n\n- [Use the library](/hub/tf2_saved_model)\n- [Reusable SavedModels](/hub/reusable_saved_models)"]]