মডেল ভ্যালিডেটর TFX পাইপলাইন কম্পোনেন্ট (অপ্রচলিত)

মডেল ভ্যালিডেটরটি একটি মডেল উৎপাদনে ব্যবহার করার জন্য যথেষ্ট ভাল ছিল কিনা তা পরীক্ষা করার জন্য ব্যবহার করা হয়েছিল। আমরা এখনও মনে করি যে বৈধতা কার্যকর, কিন্তু যেহেতু মডেল ইভালুয়েটর ইতিমধ্যেই সমস্ত মেট্রিকগুলিকে গণনা করেছে যেগুলির বিরুদ্ধে আপনি যাচাই করতে চান আমরা দুটিকে ফিউজ করার সিদ্ধান্ত নিয়েছি তাই আপনাকে গণনাগুলির নকল করতে হবে না৷

যদিও আমরা মডেল ভ্যালিডেটরকে অবমূল্যায়ন করেছি এবং এটি ব্যবহার করার পরামর্শ দিই না, আপনার যদি একটি বিদ্যমান মডেল ভ্যালিডেটর উপাদান বজায় রাখার প্রয়োজন হয় একটি উদাহরণ কনফিগারেশন নিম্নরূপ:

import tfx
import tensorflow_model_analysis as tfma
from tfx.components.model_validator.component import ModelValidator

...

model_validator = ModelValidator(
      examples=example_gen.outputs['output_data'],
      model=trainer.outputs['model'])

যারা কনফিগারেশনটি মূল্যায়নকারীতে স্থানান্তর করতে চান তাদের জন্য, মূল্যায়নকারীর জন্য একটি অনুরূপ কনফিগারেশন নিম্নরূপ দেখাবে:

from tfx import components
import tensorflow_model_analysis as tfma

...

eval_config = tfma.EvalConfig(
    model_specs=[
        # This assumes a serving model with signature 'serving_default'. If
        # using estimator based EvalSavedModel, add signature_name: 'eval' and
        # remove the label_key.
        tfma.ModelSpec(label_key='<label_key>')
    ],
    metrics_specs=[
        tfma.MetricsSpec(
            # The metrics added here are in addition to those saved with the
            # model (assuming either a keras model or EvalSavedModel is used).
            # Any metrics added into the saved model (for example using
            # model.compile(..., metrics=[...]), etc) will be computed
            # automatically.
            metrics=[
                tfma.MetricConfig(class_name='ExampleCount'),
                tfma.MetricConfig(
                    class_name='BinaryAccuracy',
                    threshold=tfma.MetricThreshold(
                        value_threshold=tfma.GenericValueThreshold(
                            lower_bound={'value': 0.5}),
                        change_threshold=tfma.GenericChangeThreshold(
                            direction=tfma.MetricDirection.HIGHER_IS_BETTER,
                            absolute={'value': -1e-10})))
            ]
        )
    ],
    slicing_specs=[
        # An empty slice spec means the overall slice, i.e. the whole dataset.
        tfma.SlicingSpec(),
        # Data can be sliced along a feature column. In this case, data is
        # sliced along feature column trip_start_hour.
        tfma.SlicingSpec(feature_keys=['trip_start_hour'])
    ])

model_resolver = Resolver(
      strategy_class=latest_blessed_model_resolver.LatestBlessedModelResolver,
      model=Channel(type=Model),
      model_blessing=Channel(type=ModelBlessing)
).with_id('latest_blessed_model_resolver')

model_analyzer = components.Evaluator(
      examples=examples_gen.outputs['examples'],
      model=trainer.outputs['model'],
      baseline_model=model_resolver.outputs['model'],
      # Change threshold will be ignored if there is no baseline (first run).
      eval_config=eval_config)