نظرة عامة على مكتبة 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
دليلاً مؤقتًا على مستوى النظام لتخزين النماذج التي تم تنزيلها وغير المضغوطة مؤقتًا. راجع التخزين المؤقت للحصول على خيارات لاستخدام مواقع أخرى، وربما أكثر ثباتًا.
استقرار واجهة برمجة التطبيقات
على الرغم من أننا نأمل في منع حدوث تغييرات، إلا أن هذا المشروع لا يزال قيد التطوير النشط وليس مضمونًا بعد أن يكون لديه واجهة برمجة تطبيقات مستقرة أو تنسيق نموذج.
الإنصاف
كما هو الحال في جميع مجالات التعلم الآلي، تعد العدالة أحد الاعتبارات المهمة . يتم تدريب العديد من النماذج المدربة مسبقًا على مجموعات البيانات الكبيرة. عند إعادة استخدام أي نموذج، من المهم أن تضع في اعتبارك البيانات التي تم تدريب النموذج عليها (وما إذا كان هناك أي تحيزات موجودة هناك)، وكيف يمكن أن يؤثر ذلك على استخدامك له.
حماية
نظرًا لأنها تحتوي على رسوم بيانية اعتباطية لـ TensorFlow، فيمكن اعتبار النماذج بمثابة برامج. يصف استخدام TensorFlow بشكل آمن الآثار الأمنية المترتبة على الرجوع إلى نموذج من مصدر غير موثوق به.
الخطوات التالية
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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)"]]