การตั้งค่าการวิเคราะห์โมเดล 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"}] }
- ชิ้นที่ประกอบด้วย "country: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 สามารถใช้เพื่อสร้างอินสแตนซ์เริ่มต้นที่กำหนดเส้นทางและชุดแท็กได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],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."]]