إعداد تحليل نموذج Tensorflow
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
إعدادات
يقوم TFMA بتخزين التكوين الخاص به في نموذج أولي يتم تسلسله إلى JSON. يقوم هذا النموذج الأولي بدمج التكوين المطلوب لبيانات الإدخال وبيانات الإخراج ومواصفات النموذج والمواصفات المترية ومواصفات التقطيع.
ترتبط جميع خطوط أنابيب TFMA بنموذج أساسي (أساسي) ونماذج مرشحة (ثانوية) صفر أو أكثر. يتم تعريف خط الأساس والنموذج المرشح من قبل المستخدم في بداية المسار ويتطلب كل منهما اسمًا فريدًا. فيما يلي أمثلة على إعدادات التكوين النموذجية التي قد يستخدمها المستخدم:
- تقييم نموذج واحد:
- التقييم القائم على التحقق من الصحة:
- تقييم مقارنة النموذج:
مواصفات النموذج
مواصفات النموذج هي من النوع tfma.ModelSpec
وتستخدم لتحديد موقع النموذج بالإضافة إلى المعلمات الأخرى الخاصة بالنموذج. على سبيل المثال، ما يلي هو الإعدادات النموذجية التي يجب تكوينها قبل إجراء التقييم:
-
name
- اسم النموذج (في حالة استخدام نماذج متعددة) -
signature_name
- اسم التوقيع المستخدم للتنبؤات (الافتراضي هو serving_default
). استخدم eval
في حالة استخدام EvalSavedModel. -
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"}] }
- شرائح لجميع القيم في ميزة "البلد" متقاطعة مع القيمة "العمر:20"
لاحظ أن مفاتيح الميزات قد تكون إما ميزات محولة أو ميزات إدخال أولية. راجع tfma.SlicingSpec
لمزيد من المعلومات.
EvalSharedModel
بالإضافة إلى إعدادات التكوين، يتطلب TFMA أيضًا إنشاء مثيل tfma.EvalSharedModel
لمشاركة نموذج بين عدة سلاسل رسائل في نفس العملية. يتضمن مثيل النموذج المشترك معلومات حول نوع النموذج (keras، وما إلى ذلك) وكيفية تحميل النموذج وتكوينه من موقعه المحفوظ على القرص (مثل العلامات، وما إلى ذلك). يمكن استخدام tfma.default_eval_shared_model
API لإنشاء مثيل افتراضي بمسار ومجموعة من العلامات.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة 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."]]