我在使用 TFX 的 StatisticsGen 组件时遇到问题。我使用 TFRecords 并使用 RaggedTensors 作为输入数据(TFrecord 是使用 SequenceExample 创建的) 在使用将文件正确拆分为 train 和 val 的 ExampleGen 后,StatisticsGen 创建了一个 0kb 文件,因此无法正常工作。
谁能向我确认 TFX 支持 RaggedTensors 吗?如果是这样,你能帮我生成统计数据吗?
TF 版本:2.4.1 Eager 模式:True TFX 版本:0.28.0 TFDV 版本:0.28.0 TFT 版本:0.28.0 TFMA 版本:0.28.0 Hub 版本:0.9.0 Beam 版本:2.28.0
!pip install tfx
import tensorflow as tf
from tfx.components import ImportExampleGen
from tfx.components import SchemaGen
from tfx.components import StatisticsGen
from tfx.utils.dsl_utils import external_input
from tfx.proto import example_gen_pb2
from tfx.orchestration.experimental.interactive.interactive_context import InteractiveContext
import tfx
import os
import apache_beam as beam
import tensorflow_data_validation as tfdv
import tensorflow_transform as tft
import tensorflow_model_analysis as tfma
import tensorflow_hub as hub
import logging
path_to_test = os.path.join("tf_records")
context = InteractiveContext(pipeline_root='pipeline_root')
#examplegen
example_gen = ImportExampleGen(input_base=path_to_test)
context.run(example_gen, enable_cache=True)
print(example_gen.outputs['examples'].get()[0].uri)
train_uri = os.path.join(example_gen.outputs['examples'].get()[0].uri, 'train')
tfrecord_filenames = [os.path.join(train_uri, name)
for name in os.listdir(train_uri)]
#statisticsgen
statistics_gen = StatisticsGen(
examples=example_gen.outputs['examples'])
context.run(statistics_gen)
context.show(statistics_gen.outputs['statistics'])