【发布时间】:2020-03-07 11:56:06
【问题描述】:
您好,我正在尝试让 TFX 流水线运行起来,就像真正的练习一样。我正在使用ImportExampleGen 从磁盘加载TFRecords。 TFRecord 中的每个Example 都包含一个字节串形式的jpg,高度、宽度、深度、转向和油门标签。
我正在尝试使用StatisticsGen,但收到此警告;
WARNING:root:Feature "image_raw" has bytes value "None" which cannot be decoded as a UTF-8 string. 让我的 Colab Notebook 崩溃。据我所知,TFRecord 中的所有字节字符串图像都没有损坏。
我在StatisticsGen 和处理图像数据方面找不到具体示例。根据docsTensorflow Data Validation 可以处理图片数据。
除了计算一组默认的数据统计信息外,TFDV 还可以计算语义域(例如图像、文本)的统计信息。要启用语义域统计信息的计算,请将 enable_semantic_domain_stats 设置为 True 的 tfdv.StatsOptions 对象传递给 tfdv.generate_statistics_from_tfrecord。
但我不确定这是否适合 StatisticsGen。
这是实例化 ImportExampleGen 然后是 StatisticsGen 的代码
from tfx.utils.dsl_utils import tfrecord_input
from tfx.components.example_gen.import_example_gen.component import ImportExampleGen
from tfx.proto import example_gen_pb2
examples = tfrecord_input(_tf_record_dir)
# https://www.tensorflow.org/tfx/guide/examplegen#custom_inputoutput_split
# has a good explanation of splitting the data the 'output_config' param
# Input train split is _tf_record_dir/*'
# Output 2 splits: train:eval=8:2.
train_ratio = 8
eval_ratio = 10-train_ratio
output = example_gen_pb2.Output(
split_config=example_gen_pb2.SplitConfig(splits=[
example_gen_pb2.SplitConfig.Split(name='train',
hash_buckets=train_ratio),
example_gen_pb2.SplitConfig.Split(name='eval',
hash_buckets=eval_ratio)
]))
example_gen = ImportExampleGen(input=examples,
output_config=output)
context.run(example_gen)
statistics_gen = StatisticsGen(
examples=example_gen.outputs['examples'])
context.run(statistics_gen)
提前致谢。
【问题讨论】:
-
更新:我一直在做一些挖掘工作。 TFX StatisticsGen Docs 靠在 tfx.data_validation 上,这让我尝试了这个;
stats = tfdv.generate_statistics_from_tfrecord(data_location=tfrecords_filename)导致相同的警告和 Colab 崩溃。我猜想找到问题的根源。 -
嗯,好的,所以我找到了一个 CIFAR 10 example,其中已经创建了一个 tfrecord。当我使用它来创建 StatisticsGen 时,我收到了同样的警告,并且我的 Google Colab 崩溃了。也许只是 Colab 对文本输出感到不知所措。也许我可以更改日志级别。看看有没有帮助。
-
您找到解决此问题的方法了吗?我有同样的错误信息。
-
有一个类似的问题,修复是更新到 tfx 21.2,让事情在上面的笔记本中以交互方式工作。更新到 21.2 也可以在 kubeflow 上运行(确保更新您的 dockerfile,我已经将这个示例与上面类似地调整为使用 ImportExampleGen github.com/tensorflow/tfx/blob/master/tfx/examples/…)
-
谢谢@DarrenBrien。我会试一试,然后回复你。
标签: tensorflow tfx