با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
مقدمه
TensorFlow Hub میزبان مدل ها برای کارهای مختلف است. مدلهای مربوط به یک کار تشویق میشوند تا یک API مشترک را پیادهسازی کنند تا مصرفکنندگان مدل بتوانند به راحتی آنها را بدون تغییر کدی که از آنها استفاده میکند، مبادله کنند، حتی اگر از ناشران مختلف باشند.
هدف این است که مبادله مدل های مختلف برای یک کار مشابه به سادگی تغییر یک ابرپارامتر با مقدار رشته ای باشد. با آن، مصرف کنندگان مدل به راحتی می توانند بهترین مورد را برای مشکل خود پیدا کنند.
API SavedModel قابل استفاده مجدد، قراردادهای کلی نحوه بارگذاری SavedModel را در برنامه پایتون و استفاده مجدد از آن به عنوان بخشی از یک مدل بزرگتر TensorFlow تعریف می کند.
استفاده اساسی:
obj=hub.load("path/to/model")# That's tf.saved_model.load() after download.outputs=obj(inputs,training=False)# Invokes the tf.function obj.__call__.
برای کاربران Keras، کلاس hub.KerasLayer به این API متکی است تا SavedModel قابل استفاده مجدد را به عنوان یک لایه Keras (محافظت از کاربران Keras از جزئیات آن)، با ورودیها و خروجیها مطابق با APIهای ویژه کار که در زیر فهرست شدهاند، بپیچد.
تاریخ آخرین بهروزرسانی 2025-01-04 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-01-04 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Common SavedModel APIs for TF Hub\n\n\u003cbr /\u003e\n\nIntroduction\n------------\n\n[TensorFlow Hub](https://tfhub.dev) hosts models for a variety of tasks. Models\nfor the same task are encouraged to implement a common API so that model\nconsumers can easily exchange them without modifying the code that uses them,\neven if they come from different publishers.\n\nThe goal is to make exchanging different models for the same task as simple as\nswitching a string-valued hyperparameter. With that, model consumers can easily\nfind the best one for their problem.\n\nThis directory collects specifications of common APIs for models in the\n[TF2 SavedModel format](../tf2_saved_model). (It replaces the\n[Common Signatures](../common_signatures/index) for the now-deprecated\n[TF1 Hub format](../tf1_hub_module).)\n\nReusable SavedModel: the common foundation\n------------------------------------------\n\nThe [Reusable SavedModel API](../reusable_saved_models) defines general\nconventions how to load a SavedModel back into a Python program and reuse it as\npart of a bigger TensorFlow model.\n\nBasic usage: \n\n obj = hub.load(\"path/to/model\") # That's tf.saved_model.load() after download.\n outputs = obj(inputs, training=False) # Invokes the tf.function obj.__call__.\n\n| **Key Point:** This uses the object-based interface to restored SavedModels that was added in TensorFlow 2, not the SavedModel signatures for serving.\n\nFor Keras users, the [`hub.KerasLayer`](https://www.tensorflow.org/hub/api_docs/python/hub/KerasLayer) class relies on this API to wrap the\nReusable SavedModel as a Keras Layer (shielding Keras users from its details),\nwith inputs and outputs according to the task-specific APIs listed below.\n\nTask-specific APIs\n------------------\n\nThese refine the [Reusable SavedModel API](../reusable_saved_models) with\nconventions for particular ML tasks and types of data.\n\n- [Image tasks](/hub/common_saved_model_apis/images)\n- [Text tasks](/hub/common_saved_model_apis/text)"]]