एमएल मेटाडेटा के साथ बेहतर एमएल इंजीनियरिंग

TensorFlow.org पर देखें Google Colab में चलाएं GitHub पर स्रोत देखें नोटबुक डाउनलोड करें

एक परिदृश्य मान लें जहां आप पेंगुइन को वर्गीकृत करने के लिए एक उत्पादन एमएल पाइपलाइन स्थापित करते हैं। पाइपलाइन आपके प्रशिक्षण डेटा को शामिल करती है, एक मॉडल को प्रशिक्षित करती है और उसका मूल्यांकन करती है, और इसे उत्पादन के लिए प्रेरित करती है।

हालाँकि, जब आप बाद में इस मॉडल का उपयोग बड़े डेटासेट के साथ करने का प्रयास करते हैं जिसमें विभिन्न प्रकार के पेंगुइन होते हैं, तो आप देखते हैं कि आपका मॉडल अपेक्षित व्यवहार नहीं करता है और प्रजातियों को गलत तरीके से वर्गीकृत करना शुरू कर देता है।

इस समय, आप जानने में रुचि रखते हैं:

  • मॉडल को डीबग करने का सबसे प्रभावी तरीका क्या है जब उत्पादन में एकमात्र उपलब्ध आर्टिफैक्ट मॉडल है?
  • मॉडल को प्रशिक्षित करने के लिए किस प्रशिक्षण डेटासेट का उपयोग किया गया था?
  • किस प्रशिक्षण रन ने इस गलत मॉडल को जन्म दिया?
  • मॉडल मूल्यांकन के परिणाम कहां हैं?
  • डिबगिंग कहां से शुरू करें?

एमएल मेटाडाटा (MLMD) एक पुस्तकालय है कि आप और अधिक इन सवालों के जवाब में मदद करने के एमएल मॉडल के साथ जुड़ा मेटाडेटा का लाभ उठाता है है। इस मेटाडेटा को सॉफ़्टवेयर विकास में लॉगिंग के समतुल्य के रूप में सोचना एक सहायक सादृश्य है। MLMD आपको अपनी ML पाइपलाइन के विभिन्न घटकों से जुड़ी कलाकृतियों और वंश को मज़बूती से ट्रैक करने में सक्षम बनाता है।

इस ट्यूटोरियल में, आपने एक मॉडल बनाने के लिए एक TFX पाइपलाइन की स्थापना की है, जो पेंगुइन को शरीर के द्रव्यमान और उनके पुलियों की लंबाई और गहराई और उनके फ्लिपर्स की लंबाई के आधार पर तीन प्रजातियों में वर्गीकृत करती है। फिर आप पाइपलाइन घटकों के वंश को ट्रैक करने के लिए एमएलएमडी का उपयोग करते हैं।

Colab . में TFX पाइपलाइन

Colab एक हल्का विकास परिवेश है जो उत्पादन परिवेश से महत्वपूर्ण रूप से भिन्न है। उत्पादन में, आपके पास विभिन्न पाइपलाइन घटक हो सकते हैं जैसे डेटा अंतर्ग्रहण, परिवर्तन, मॉडल प्रशिक्षण, रन इतिहास, आदि कई वितरित प्रणालियों में। इस ट्यूटोरियल के लिए, आपको पता होना चाहिए कि ऑर्केस्ट्रेशन और मेटाडेटा स्टोरेज में महत्वपूर्ण अंतर मौजूद हैं - यह सब Colab के भीतर स्थानीय रूप से नियंत्रित किया जाता है। Colab में TFX बारे में और जानें यहाँ

सेट अप

सबसे पहले, हम आवश्यक पैकेज स्थापित और आयात करते हैं, पथ सेट करते हैं, और डेटा डाउनलोड करते हैं।

पिप अपग्रेड करें

स्थानीय रूप से चलते समय सिस्टम में पिप को अपग्रेड करने से बचने के लिए, यह सुनिश्चित करने के लिए जांचें कि हम कोलाब में चल रहे हैं। स्थानीय प्रणालियों को निश्चित रूप से अलग से अपग्रेड किया जा सकता है।

try:
  import colab
  !pip install --upgrade pip
except:
  pass

टीएफएक्स स्थापित और आयात करें

pip install -q -U tfx

पैकेज आयात करें

क्या आपने रनटाइम को पुनरारंभ किया?

यदि आप Google Colab का उपयोग कर रहे हैं, जब आप पहली बार ऊपर सेल चलाते हैं, तो आपको "रनटाइम को पुनरारंभ करें" बटन पर क्लिक करके या "रनटाइम> रनटाइम पुनरारंभ करें ..." मेनू का उपयोग करके रनटाइम को पुनरारंभ करना होगा। ऐसा इसलिए है क्योंकि Colab संकुल को लोड करता है।

import os
import tempfile
import urllib
import pandas as pd

import tensorflow_model_analysis as tfma
from tfx.orchestration.experimental.interactive.interactive_context import InteractiveContext

टीएफएक्स, और एमएलएमडी संस्करणों की जांच करें।

from tfx import v1 as tfx
print('TFX version: {}'.format(tfx.__version__))
import ml_metadata as mlmd
print('MLMD version: {}'.format(mlmd.__version__))
TFX version: 1.4.0
MLMD version: 1.4.0

डेटासेट डाउनलोड करें

इस colab में, हम का उपयोग पामर पेंगुइन डाटासेट पर पाया जा सकता है Github । हम किसी भी अधूरा रिकॉर्ड बाहर छोड़ कर डाटासेट संसाधित, और चला जाता है island और sex स्तंभ, और करने के लिए लेबल परिवर्तित int32 । डेटासेट में बॉडी मास के 334 रिकॉर्ड और पेंगुइन के कुलमेन की लंबाई और गहराई और उनके फ्लिपर्स की लंबाई होती है। आप इस डेटा का उपयोग पेंगुइन को तीन प्रजातियों में से एक में वर्गीकृत करने के लिए करते हैं।

DATA_PATH = 'https://raw.githubusercontent.com/tensorflow/tfx/master/tfx/examples/penguin/data/labelled/penguins_processed.csv'
_data_root = tempfile.mkdtemp(prefix='tfx-data')
_data_filepath = os.path.join(_data_root, "penguins_processed.csv")
urllib.request.urlretrieve(DATA_PATH, _data_filepath)
('/tmp/tfx-datal9104odr/penguins_processed.csv',
 <http.client.HTTPMessage at 0x7f9c6d8d2290>)

एक इंटरएक्टिव कॉन्टेक्स्ट बनाएं

TFX घटकों को चलाने के लिए सहभागी इस नोटबुक में, एक बनाने InteractiveContextInteractiveContext एक अल्पकालिक MLMD डेटाबेस उदाहरण के साथ एक अस्थायी निर्देशिका का उपयोग करता है। ध्यान दें कि करने के लिए कॉल InteractiveContext Colab वातावरण से बाहर नहीं-ऑप्स कर रहे हैं।

सामान्य तौर पर, यह एक के तहत समूह समान पाइपलाइन रन करने के लिए एक अच्छा अभ्यास है Context

interactive_context = InteractiveContext()
WARNING:absl:InteractiveContext pipeline_root argument not provided: using temporary directory /tmp/tfx-interactive-2021-12-05T11_15_56.285625-5hcexlo8 as root for pipeline outputs.
WARNING:absl:InteractiveContext metadata_connection_config not provided: using SQLite ML Metadata database at /tmp/tfx-interactive-2021-12-05T11_15_56.285625-5hcexlo8/metadata.sqlite.

TFX पाइपलाइन का निर्माण करें

एक TFX पाइपलाइन में कई घटक होते हैं जो ML वर्कफ़्लो के विभिन्न पहलुओं को निष्पादित करते हैं। इस नोटबुक में, आप बना सकते हैं और चलाने ExampleGen , StatisticsGen , SchemaGen , और Trainer घटकों और का उपयोग Evaluator और Pusher का मूल्यांकन करने और प्रशिक्षित मॉडल पुश करने के लिए घटक।

का संदर्भ लें घटकों ट्यूटोरियल TFX पाइपलाइन घटकों के बारे में अधिक जानकारी के लिए।

इंस्टेंट करें और exampleGen कंपोनेंट चलाएँ

example_gen = tfx.components.CsvExampleGen(input_base=_data_root)
interactive_context.run(example_gen)
WARNING:apache_beam.runners.interactive.interactive_environment:Dependencies required for Interactive Beam PCollection visualization are not available, please use: `pip install apache-beam[interactive]` to install necessary dependencies to enable all data visualization features.
WARNING:root:Make sure that locally built Python SDK docker image has Python 3.7 interpreter.
WARNING:apache_beam.io.tfrecordio:Couldn't find python-snappy so the implementation of _TFRecordUtil._masked_crc32c is not as fast as it could be.

स्टैटिस्टिक्सजेन कंपोनेंट को इंस्टेंट करें और चलाएं

statistics_gen = tfx.components.StatisticsGen(
    examples=example_gen.outputs['examples'])
interactive_context.run(statistics_gen)
WARNING:root:Make sure that locally built Python SDK docker image has Python 3.7 interpreter.

स्कीमाजेन कंपोनेंट को इंस्टेंट करें और चलाएं

infer_schema = tfx.components.SchemaGen(
    statistics=statistics_gen.outputs['statistics'], infer_feature_shape=True)
interactive_context.run(infer_schema)
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1205 11:16:00.941947  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type

ट्रेनर कंपोनेंट को इंस्टेंट करें और चलाएं

# Define the module file for the Trainer component
trainer_module_file = 'penguin_trainer.py'
%%writefile {trainer_module_file}

# Define the training algorithm for the Trainer module file
import os
from typing import List, Text

import tensorflow as tf
from tensorflow import keras

from tfx import v1 as tfx
from tfx_bsl.public import tfxio

from tensorflow_metadata.proto.v0 import schema_pb2

# Features used for classification - culmen length and depth, flipper length,
# body mass, and species.

_LABEL_KEY = 'species'

_FEATURE_KEYS = [
    'culmen_length_mm', 'culmen_depth_mm', 'flipper_length_mm', 'body_mass_g'
]


def _input_fn(file_pattern: List[Text],
              data_accessor: tfx.components.DataAccessor,
              schema: schema_pb2.Schema, batch_size: int) -> tf.data.Dataset:
  return data_accessor.tf_dataset_factory(
      file_pattern,
      tfxio.TensorFlowDatasetOptions(
          batch_size=batch_size, label_key=_LABEL_KEY), schema).repeat()


def _build_keras_model():
  inputs = [keras.layers.Input(shape=(1,), name=f) for f in _FEATURE_KEYS]
  d = keras.layers.concatenate(inputs)
  d = keras.layers.Dense(8, activation='relu')(d)
  d = keras.layers.Dense(8, activation='relu')(d)
  outputs = keras.layers.Dense(3)(d)
  model = keras.Model(inputs=inputs, outputs=outputs)
  model.compile(
      optimizer=keras.optimizers.Adam(1e-2),
      loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
      metrics=[keras.metrics.SparseCategoricalAccuracy()])
  return model


def run_fn(fn_args: tfx.components.FnArgs):
  schema = schema_pb2.Schema()
  tfx.utils.parse_pbtxt_file(fn_args.schema_path, schema)
  train_dataset = _input_fn(
      fn_args.train_files, fn_args.data_accessor, schema, batch_size=10)
  eval_dataset = _input_fn(
      fn_args.eval_files, fn_args.data_accessor, schema, batch_size=10)
  model = _build_keras_model()
  model.fit(
      train_dataset,
      epochs=int(fn_args.train_steps / 20),
      steps_per_epoch=20,
      validation_data=eval_dataset,
      validation_steps=fn_args.eval_steps)
  model.save(fn_args.serving_model_dir, save_format='tf')
Writing penguin_trainer.py

भागो Trainer घटक।

trainer = tfx.components.Trainer(
    module_file=os.path.abspath(trainer_module_file),
    examples=example_gen.outputs['examples'],
    schema=infer_schema.outputs['schema'],
    train_args=tfx.proto.TrainArgs(num_steps=100),
    eval_args=tfx.proto.EvalArgs(num_steps=50))
interactive_context.run(trainer)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
copying penguin_trainer.py -> build/lib
installing to /tmp/tmpum1crtxy
running install
running install_lib
copying build/lib/penguin_trainer.py -> /tmp/tmpum1crtxy
running install_egg_info
running egg_info
creating tfx_user_code_Trainer.egg-info
writing tfx_user_code_Trainer.egg-info/PKG-INFO
writing dependency_links to tfx_user_code_Trainer.egg-info/dependency_links.txt
writing top-level names to tfx_user_code_Trainer.egg-info/top_level.txt
writing manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'
reading manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'
writing manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'
Copying tfx_user_code_Trainer.egg-info to /tmp/tmpum1crtxy/tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4-py3.7.egg-info
running install_scripts
creating /tmp/tmpum1crtxy/tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4.dist-info/WHEEL
creating '/tmp/tmpo87nn6ey/tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4-py3-none-any.whl' and adding '/tmp/tmpum1crtxy' to it
adding 'penguin_trainer.py'
adding 'tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4.dist-info/METADATA'
adding 'tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4.dist-info/WHEEL'
adding 'tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4.dist-info/top_level.txt'
adding 'tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4.dist-info/RECORD'
removing /tmp/tmpum1crtxy
/tmpfs/src/tf_docs_env/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  setuptools.SetuptoolsDeprecationWarning,
listing git files failed - pretending there aren't any
I1205 11:16:01.389324  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type
I1205 11:16:01.392832  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type
Processing /tmp/tfx-interactive-2021-12-05T11_15_56.285625-5hcexlo8/_wheels/tfx_user_code_Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4-py3-none-any.whl
Installing collected packages: tfx-user-code-Trainer
Successfully installed tfx-user-code-Trainer-0.0+fef7c4ed90dc336ca26daee59d65660cf8da5fa988b2ca0c89df2f558fda10f4
Epoch 1/5
20/20 [==============================] - 1s 11ms/step - loss: 0.9891 - sparse_categorical_accuracy: 0.4300 - val_loss: 0.9594 - val_sparse_categorical_accuracy: 0.4800
Epoch 2/5
20/20 [==============================] - 0s 6ms/step - loss: 0.8369 - sparse_categorical_accuracy: 0.6350 - val_loss: 0.7484 - val_sparse_categorical_accuracy: 0.8200
Epoch 3/5
20/20 [==============================] - 0s 6ms/step - loss: 0.5289 - sparse_categorical_accuracy: 0.8350 - val_loss: 0.5068 - val_sparse_categorical_accuracy: 0.7800
Epoch 4/5
20/20 [==============================] - 0s 6ms/step - loss: 0.4481 - sparse_categorical_accuracy: 0.7800 - val_loss: 0.4125 - val_sparse_categorical_accuracy: 0.8600
Epoch 5/5
20/20 [==============================] - 0s 6ms/step - loss: 0.3068 - sparse_categorical_accuracy: 0.8650 - val_loss: 0.3279 - val_sparse_categorical_accuracy: 0.8300
2021-12-05 11:16:06.493168: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them.
INFO:tensorflow:Assets written to: /tmp/tfx-interactive-2021-12-05T11_15_56.285625-5hcexlo8/Trainer/model/4/Format-Serving/assets
INFO:tensorflow:Assets written to: /tmp/tfx-interactive-2021-12-05T11_15_56.285625-5hcexlo8/Trainer/model/4/Format-Serving/assets

मॉडल का मूल्यांकन करें और उसे आगे बढ़ाएं

का प्रयोग करें Evaluator मूल्यांकन करने के लिए और उपयोग करने से पहले मॉडल 'आशीर्वाद' घटक Pusher घटक एक सेवारत निर्देशिका के लिए मॉडल पुश करने के लिए।

_serving_model_dir = os.path.join(tempfile.mkdtemp(),
                                  'serving_model/penguins_classification')
eval_config = tfma.EvalConfig(
    model_specs=[
        tfma.ModelSpec(label_key='species', signature_name='serving_default')
    ],
    metrics_specs=[
        tfma.MetricsSpec(metrics=[
            tfma.MetricConfig(
                class_name='SparseCategoricalAccuracy',
                threshold=tfma.MetricThreshold(
                    value_threshold=tfma.GenericValueThreshold(
                        lower_bound={'value': 0.6})))
        ])
    ],
    slicing_specs=[tfma.SlicingSpec()])
evaluator = tfx.components.Evaluator(
    examples=example_gen.outputs['examples'],
    model=trainer.outputs['model'],
    schema=infer_schema.outputs['schema'],
    eval_config=eval_config)
interactive_context.run(evaluator)
I1205 11:16:07.075275  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type
I1205 11:16:07.078761  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type
WARNING:root:Make sure that locally built Python SDK docker image has Python 3.7 interpreter.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.7/site-packages/tensorflow_model_analysis/writers/metrics_plots_and_validations_writer.py:114: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and: 
`tf.data.TFRecordDataset(path)`
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.7/site-packages/tensorflow_model_analysis/writers/metrics_plots_and_validations_writer.py:114: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and: 
`tf.data.TFRecordDataset(path)`
pusher = tfx.components.Pusher(
    model=trainer.outputs['model'],
    model_blessing=evaluator.outputs['blessing'],
    push_destination=tfx.proto.PushDestination(
        filesystem=tfx.proto.PushDestination.Filesystem(
            base_directory=_serving_model_dir)))
interactive_context.run(pusher)
I1205 11:16:11.935312  6108 rdbms_metadata_access_object.cc:686] No property is defined for the Type

TFX पाइपलाइन चलाना MLMD डेटाबेस को पॉप्युलेट करता है। अगले भाग में, आप मेटाडेटा जानकारी के लिए इस डेटाबेस को क्वेरी करने के लिए MLMD API का उपयोग करते हैं।

MLMD डेटाबेस को क्वेरी करें

MLMD डेटाबेस तीन प्रकार के मेटाडेटा को संग्रहीत करता है:

  • पाइपलाइन घटकों से जुड़ी पाइपलाइन और वंश संबंधी जानकारी के बारे में मेटाडेटा
  • पाइपलाइन चलाने के दौरान उत्पन्न कलाकृतियों के बारे में मेटाडेटा
  • पाइपलाइन के निष्पादन के बारे में मेटाडेटा

जैसे ही नया डेटा आता है, एक विशिष्ट उत्पादन वातावरण पाइपलाइन कई मॉडल पेश करती है। जब आप प्रस्तुत मॉडल में गलत परिणाम प्राप्त करते हैं, तो आप गलत मॉडल को अलग करने के लिए एमएलएमडी डेटाबेस को क्वेरी कर सकते हैं। फिर आप अपने मॉडल को डीबग करने के लिए इन मॉडलों के अनुरूप पाइपलाइन घटकों के वंश का पता लगा सकते हैं

मेटाडाटा (एमडी) की दुकान सेट अप के साथ InteractiveContext पहले से परिभाषित MLMD डेटाबेस क्वेरी करने के लिए।

connection_config = interactive_context.metadata_connection_config
store = mlmd.MetadataStore(connection_config)

# All TFX artifacts are stored in the base directory
base_dir = connection_config.sqlite.filename_uri.split('metadata.sqlite')[0]

एमडी स्टोर से डेटा देखने के लिए कुछ हेल्पर फंक्शन बनाएं।

def display_types(types):
  # Helper function to render dataframes for the artifact and execution types
  table = {'id': [], 'name': []}
  for a_type in types:
    table['id'].append(a_type.id)
    table['name'].append(a_type.name)
  return pd.DataFrame(data=table)
def display_artifacts(store, artifacts):
  # Helper function to render dataframes for the input artifacts
  table = {'artifact id': [], 'type': [], 'uri': []}
  for a in artifacts:
    table['artifact id'].append(a.id)
    artifact_type = store.get_artifact_types_by_id([a.type_id])[0]
    table['type'].append(artifact_type.name)
    table['uri'].append(a.uri.replace(base_dir, './'))
  return pd.DataFrame(data=table)
def display_properties(store, node):
  # Helper function to render dataframes for artifact and execution properties
  table = {'property': [], 'value': []}
  for k, v in node.properties.items():
    table['property'].append(k)
    table['value'].append(
        v.string_value if v.HasField('string_value') else v.int_value)
  for k, v in node.custom_properties.items():
    table['property'].append(k)
    table['value'].append(
        v.string_value if v.HasField('string_value') else v.int_value)
  return pd.DataFrame(data=table)

सबसे पहले, अपने सभी संग्रहीत की सूची के लिए क्वेरी एमडी दुकान ArtifactTypes

display_types(store.get_artifact_types())

इसके बाद, क्वेरी सभी PushedModel कलाकृतियों।

pushed_models = store.get_artifacts_by_type("PushedModel")
display_artifacts(store, pushed_models)

नवीनतम पुश किए गए मॉडल के लिए एमडी स्टोर को क्वेरी करें। इस ट्यूटोरियल में केवल एक पुश मॉडल है।

pushed_model = pushed_models[-1]
display_properties(store, pushed_model)

पुश किए गए मॉडल को डिबग करने के पहले चरणों में से एक यह देखना है कि किस प्रशिक्षित मॉडल को धक्का दिया गया है और यह देखने के लिए कि उस मॉडल को प्रशिक्षित करने के लिए कौन से प्रशिक्षण डेटा का उपयोग किया जाता है।

MLMD ट्रैवर्सल एपीआई प्रदान करता है जो प्रोविडेंस ग्राफ के माध्यम से चलता है, जिसका उपयोग आप मॉडल प्रोविडेंस का विश्लेषण करने के लिए कर सकते हैं।

def get_one_hop_parent_artifacts(store, artifacts):
  # Get a list of artifacts within a 1-hop of the artifacts of interest
  artifact_ids = [artifact.id for artifact in artifacts]
  executions_ids = set(
      event.execution_id
      for event in store.get_events_by_artifact_ids(artifact_ids)
      if event.type == mlmd.proto.Event.OUTPUT)
  artifacts_ids = set(
      event.artifact_id
      for event in store.get_events_by_execution_ids(executions_ids)
      if event.type == mlmd.proto.Event.INPUT)
  return [artifact for artifact in store.get_artifacts_by_id(artifacts_ids)]

पुश किए गए मॉडल के लिए पैरेंट कलाकृतियों को क्वेरी करें।

parent_artifacts = get_one_hop_parent_artifacts(store, [pushed_model])
display_artifacts(store, parent_artifacts)

मॉडल के लिए गुणों को क्वेरी करें।

exported_model = parent_artifacts[0]
display_properties(store, exported_model)

मॉडल के लिए अपस्ट्रीम कलाकृतियों को क्वेरी करें।

model_parents = get_one_hop_parent_artifacts(store, [exported_model])
display_artifacts(store, model_parents)

प्रशिक्षण डेटा प्राप्त करें जिसके साथ मॉडल प्रशिक्षित है।

used_data = model_parents[0]
display_properties(store, used_data)

अब जब आपके पास मॉडल द्वारा प्रशिक्षित प्रशिक्षण डेटा है, तो प्रशिक्षण चरण (निष्पादन) खोजने के लिए डेटाबेस को फिर से क्वेरी करें। पंजीकृत निष्पादन प्रकारों की सूची के लिए एमडी स्टोर से पूछताछ करें।

display_types(store.get_execution_types())

प्रशिक्षण कदम है ExecutionType नामित tfx.components.trainer.component.Trainer । पुश मॉडल के अनुरूप ट्रेनर चलाने के लिए एमडी स्टोर को पार करें।

def find_producer_execution(store, artifact):
  executions_ids = set(
      event.execution_id
      for event in store.get_events_by_artifact_ids([artifact.id])
      if event.type == mlmd.proto.Event.OUTPUT)
  return store.get_executions_by_id(executions_ids)[0]

trainer = find_producer_execution(store, exported_model)
display_properties(store, trainer)

सारांश

इस ट्यूटोरियल में, आपने सीखा कि आप अपने टीएफएक्स पाइपलाइन घटकों के वंश का पता लगाने और मुद्दों को हल करने के लिए एमएलएमडी का लाभ कैसे उठा सकते हैं।

एमएलएमडी का उपयोग करने के तरीके के बारे में और जानने के लिए, इन अतिरिक्त संसाधनों को देखें: