StatisticsGen TFX 파이프라인 구성 요소
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
StatisticsGen TFX 파이프라인 구성 요소는 다른 파이프라인 구성 요소에서 사용할 수 있는 훈련 및 적용 데이터 모두에 대한 특성 통계를 생성합니다. StatisticsGen은 Beam을 사용하여 대규모 데이터세트로 확장합니다.
- 입력: ExampleGen 파이프라인 구성 요소로 만들어진 데이터세트
- 출력: 데이터세트 통계
StatisticsGen 및 TensorFlow 데이터 검증
StatisticsGen은 데이터세트에서 통계를 생성하기 위해 TensorFlow 데이터 검증을 광범위하게 사용합니다.
StatsGen 구성 요소 사용하기
StatisticsGen 파이프라인 구성 요소는 일반적으로 배포가 매우 쉽고 사용자 정의가 거의 필요하지 않습니다. 일반적인 코드는 다음과 같습니다.
from tfx import components
...
compute_eval_stats = components.StatisticsGen(
examples=example_gen.outputs['examples'],
name='compute-eval-stats'
)
스키마와 StatsGen 구성 요소 사용하기
파이프라인의 첫 번째 실행에서 StatisticsGen의 출력은 스키마를 추론하는 데 사용됩니다. 그러나 후속 실행에서는 데이터세트에 대한 추가 정보를 포함하는 수동으로 큐레이팅된 스키마가 있을 수 있습니다. 이 스키마를 StatisticsGen에 제공함으로써 TFDV는 데이터세트의 선언된 속성을 기반으로 더 유용한 통계를 제공할 수 있습니다.
이 설정에서 다음과 같이 ImporterNode에서 가져온 큐레이팅된 스키마로 StatisticsGen을 호출합니다.
from tfx import components
from tfx.types import standard_artifacts
...
user_schema_importer = components.ImporterNode(
instance_name='import_user_schema',
source_uri=user_schema_dir, # directory containing only schema text proto
artifact_type=standard_artifacts.Schema)
compute_eval_stats = components.StatisticsGen(
examples=example_gen.outputs['examples'],
schema=user_schema_importer.outputs['result'],
name='compute-eval-stats'
)
큐레이팅된 스키마 만들기
TFX의 Schema
는 TensorFlow Metadata Schema
proto의 인스턴스입니다. 처음부터 텍스트 형식으로 구성할 수 있습니다. 하지만 SchemaGen
에서 생성한 추론된 스키마를 시작점으로 사용하기가 더 쉽습니다. SchemaGen
구성 요소가 실행되면 스키마는 다음 경로의 파이프라인 루트 아래에 있습니다.
<pipeline_root>/SchemaGen/schema/<artifact_id>/schema.pbtxt
여기서 <artifact_id>
는 MLMD에서 이 버전의 스키마에 대한 고유 ID를 나타냅니다. 그런 다음 스키마 proto를 수정하여 안정적으로 추론할 수 없는 데이터세트에 대한 정보를 전달할 수 있습니다. 그러면 StatisticsGen
의 출력이 더 유용해지고 ExampleValidator
구성 요소에서 수행되는 검증이 더 엄격해집니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2021-04-08(UTC)
[null,null,["최종 업데이트: 2021-04-08(UTC)"],[],[],null,["# The StatisticsGen TFX Pipeline Component\n\n\u003cbr /\u003e\n\nThe StatisticsGen TFX pipeline component generates features statistics\nover both training and serving data, which can be used by other pipeline\ncomponents.\nStatisticsGen uses Beam to scale to large datasets.\n\n- Consumes: datasets created by an ExampleGen pipeline component.\n- Emits: Dataset statistics.\n\nStatisticsGen and TensorFlow Data Validation\n--------------------------------------------\n\nStatisticsGen makes extensive use of [TensorFlow Data Validation](/tfx/guide/tfdv) for\ngenerating statistics from your dataset.\n\nUsing the StatsGen Component\n----------------------------\n\nA StatisticsGen pipeline component is typically very easy to deploy and requires\nlittle customization. Typical code looks like this: \n\n compute_eval_stats = StatisticsGen(\n examples=example_gen.outputs['examples'],\n name='compute-eval-stats'\n )\n\nUsing the StatsGen Component With a Schema\n------------------------------------------\n\nFor the first run of a pipeline, the output of StatisticsGen will be used to\ninfer a schema. However, on subsequent runs you may have a manually curated\nschema that contains additional information about your data set. By providing\nthis schema to StatisticsGen, TFDV can provide more useful statistics based on\ndeclared properties of your data set.\n\nIn this setting, you will invoke StatisticsGen with a curated schema that has\nbeen imported by an ImporterNode like this: \n\n user_schema_importer = Importer(\n source_uri=user_schema_dir, # directory containing only schema text proto\n artifact_type=standard_artifacts.Schema).with_id('schema_importer')\n\n compute_eval_stats = StatisticsGen(\n examples=example_gen.outputs['examples'],\n schema=user_schema_importer.outputs['result'],\n name='compute-eval-stats'\n )\n\n### Creating a Curated Schema\n\n`Schema` in TFX is an instance of the TensorFlow Metadata\n[`Schema` proto](https://github.com/tensorflow/metadata/blob/master/tensorflow_metadata/proto/v0/schema.proto).\nThis can be composed in\n[text format](https://googleapis.dev/python/protobuf/latest/google/protobuf/text_format.html)\nfrom scratch. However, it is easier to use the inferred schema produced by\n`SchemaGen` as a starting point. Once the `SchemaGen` component has executed,\nthe schema will be located under the pipeline root in the following path: \n\n \u003cpipeline_root\u003e/SchemaGen/schema/\u003cartifact_id\u003e/schema.pbtxt\n\nWhere `\u003cartifact_id\u003e` represents a unique ID for this version of the schema in\nMLMD. This schema proto can then be modified to communicate information about\nthe dataset which cannot be reliably inferred, which will make the output of\n`StatisticsGen` more useful and the validation performed in the\n[`ExampleValidator`](https://www.tensorflow.org/tfx/guide/exampleval) component\nmore stringent.\n\nMore details are available in the\n[StatisticsGen API reference](https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/components/StatisticsGen)."]]