تنظیم تحلیل مدل تنسورفلو
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پیکربندی
TFMA پیکربندی خود را در پروتویی ذخیره می کند که به صورت سریال JSON است. این پروتو پیکربندی مورد نیاز برای داده های ورودی، داده های خروجی، مشخصات مدل، مشخصات متریک، و مشخصات برش را یکپارچه می کند.
تمام خطوط لوله TFMA با یک مدل پایه (اولیه) و مدل های کاندید صفر یا بیشتر (ثانویه) مرتبط هستند. خط مبنا و مدل کاندید توسط کاربر در ابتدای خط لوله تعریف می شود و هر یک به یک نام منحصر به فرد نیاز دارند. موارد زیر نمونههایی از تنظیمات پیکربندی معمولی است که کاربر ممکن است از آن استفاده کند:
- ارزیابی تک مدل:
- ارزیابی مبتنی بر اعتبارسنجی:
- ارزیابی مقایسه مدل:
مشخصات مدل
مشخصات مدل از نوع tfma.ModelSpec
هستند و برای تعریف مکان یک مدل و همچنین سایر پارامترهای خاص مدل استفاده می شوند. برای مثال موارد زیر تنظیمات معمولی هستند که باید قبل از اجرای ارزیابی پیکربندی شوند:
-
name
- نام مدل (در صورت استفاده از چندین مدل) -
signature_name
- نام امضایی که برای پیشبینیها استفاده میشود (پیشفرض serving_default
است). در صورت استفاده از EvalSavedModel از eval
استفاده کنید. -
label_key
- نام ویژگی مرتبط با برچسب. -
example_weight_key
- نام ویژگی مرتبط با وزن مثال.
مشخصات متریک
مشخصات معیارها از نوع tfma.MetricsSpec
هستند و برای پیکربندی معیارهایی که به عنوان بخشی از ارزیابی محاسبه میشوند استفاده میشوند. مشکلات مختلف یادگیری ماشین از انواع مختلفی از معیارها استفاده می کنند و TFMA گزینه های زیادی را برای پیکربندی و سفارشی کردن معیارهای محاسبه شده ارائه می دهد. از آنجایی که معیارها بخش بسیار بزرگی از TFMA هستند، آنها به طور جداگانه در متریک مورد بحث قرار می گیرند.
مشخصات برش
مشخصات برش از نوع tfma.SlicingSpec
هستند و برای پیکربندی معیارهای برشهایی که در طول ارزیابی استفاده میشوند استفاده میشوند. برش را می توان با feature_keys
، feature_values
یا هر دو انجام داد. چند نمونه از مشخصات برش به شرح زیر است:
-
{}
- برش متشکل از داده های کلی.
-
{ feature_keys: ["country"] }
- برش برای همه مقادیر در ویژگی "کشور". برای مثال، ممکن است برشهای "country:us"، "country:jp" و غیره را دریافت کنیم.
-
{ feature_values: [{key: "country", value: "us"}] }
-
{ feature_keys: ["country", "city"] }
- تکههایی برای همه مقادیر در ویژگی "کشور" با همه مقادیر در ویژگی "شهر" تلاقی داده شده است (توجه داشته باشید که ممکن است گران باشد).
-
{ feature_keys: ["country"] feature_values: [{key: "age", value: "20"}] }
- برشها برای همه مقادیر در ویژگی "country" با مقدار "age:20" تلاقی داده شده است.
توجه داشته باشید که کلیدهای ویژگی ممکن است ویژگی های تبدیل شده یا ویژگی های ورودی خام باشند. برای اطلاعات بیشتر به tfma.SlicingSpec
مراجعه کنید.
EvalSharedModel
علاوه بر تنظیمات پیکربندی، TFMA همچنین نیاز دارد که یک نمونه از tfma.EvalSharedModel
برای به اشتراک گذاری یک مدل بین چندین رشته در یک فرآیند ایجاد شود. نمونه مدل مشترک شامل اطلاعاتی در مورد نوع مدل (keras و غیره) و نحوه بارگیری و پیکربندی مدل از مکان ذخیره شده آن بر روی دیسک (به عنوان مثال برچسب ها و غیره) است. tfma.default_eval_shared_model
API را می توان برای ایجاد یک نمونه پیش فرض با یک مسیر و مجموعه ای از برچسب ها استفاده کرد.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Tensorflow Model Analysis Setup\n\n\u003cbr /\u003e\n\nConfiguration\n-------------\n\nTFMA stores its configuration in a\n[proto](https://github.com/tensorflow/model-analysis/blob/master/tensorflow_model_analysis/proto/config.proto)\nthat is serialized to JSON. This proto consolidates the configuration required\nfor input data, output data, model specifications, metric specifications, and\nslicing specifications.\n\nAll TFMA pipelines are associated with a baseline (primary) model and zero or\nmore candidate (secondary) models. The baseline and candidate model are defined\nby the user at the start of the pipeline and each require a unique name. The\nfollowing are examples of typical configuration setups a user may use:\n\n- Single model evaluation:\n - N/A (i.e. no name)\n- Validation-based evaluation:\n - `baseline`\n - `candidate`\n- Model comparison evaluation:\n - `my_model_a`\n - `my_model_b`\n\n### Model Specs\n\nModel specs are of type [`tfma.ModelSpec`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/ModelSpec) and are used to define the location of\na model as well as other model specific parameters. For example the following\nare typical settings that would need to be configured prior to running an\nevaluation:\n\n- `name` - name of model (if multiple models used)\n- `signature_name` - name of signature used for predictions (default is `serving_default`). Use `eval` if using an EvalSavedModel.\n- `label_key` - name of the feature associated with the label.\n- `example_weight_key` - name of the feature assocated with the example weight.\n\n### Metrics Specs\n\nMetrics specs are of type [`tfma.MetricsSpec`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/MetricsSpec) and are used to configure the\nmetrics that will be calculated as part of the evaluation. Different machine\nlearning problems use different types of metrics and TFMA offers a lot of\noptions for configuring and customizing the metrics that are computed. Since\nmetrics are a very large part of TFMA, they are discussed in detail separately\nin [metrics](/tfx/model_analysis/metrics).\n\n### Slicing Specs\n\nSlicing specs are of type [`tfma.SlicingSpec`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/SlicingSpec) and are used to configure the\nslices criteria that will be used during the evaluation. Slicing can be done\neither by `feature_keys`, `feature_values`, or both. Some examples of slicing\nspecs are as follows:\n\n- `{}`\n - Slice consisting of overall data.\n- `{ feature_keys: [\"country\"] }`\n - Slices for all values in feature \"country\". For example, we might get slices \"country:us\", \"country:jp\", etc.\n- `{ feature_values: [{key: \"country\", value: \"us\"}] }`\n - Slice consisting of \"country:us\".\n- `{ feature_keys: [\"country\", \"city\"] }`\n - Slices for all values in feature \"country\" crossed with all values in feature \"city\" (note this may be expensive).\n- `{ feature_keys: [\"country\"] feature_values: [{key: \"age\", value: \"20\"}] }`\n - Slices for all values in feature \"country\" crossed with value \"age:20\"\n\nNote that feature keys may be either transformed features or raw input features.\nSee [`tfma.SlicingSpec`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/SlicingSpec) for more information.\n\nEvalSharedModel\n---------------\n\nIn addition to the configuration settings, TFMA also requires that an instance\nof a [`tfma.EvalSharedModel`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/types/EvalSharedModel) be created for sharing a model between multiple\nthreads in the same process. The shared model instance includes information\nabout the type of model (keras, etc) and how to load and configure the model\nfrom its saved location on disk (e.g. tags, etc). The\n[`tfma.default_eval_shared_model`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/default_eval_shared_model) API can be used to create a default instance\ngiven a path and set of tags."]]