![](/img/trans.png)
[英]How can i run my apache beam pipeline with a local CSV-File when using Tensorflow Extended?
[英]Can I pass side inputs to Apache Beam PTransforms?
我正在使用Apache Beam預處理TensorFlow的數據。 我想根據數據集中的示例數量選擇TFRecord分片的數量。 相關的代碼部分是:
EXAMPLES_PER_SHARD = 5.0
num_tfexamples = tfexample_strs | "count tf examples" >> beam.combiners.Count.Globally()
num_shards = num_tfexamples | ("compute number of shards" >>
beam.Map(lambda num_examples: int(math.ceil(num_examples / EXAMPLES_PER_SHARD))))
_ = tfexample_strs | ("output to tfrecords" >>
beam.io.WriteToTFRecord(OUTPUT_DIR, num_shards=beam.pvalue.AsSingleton(num_shards)))
這與堆棧跟蹤失敗:
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/iobase.py", line 1011, in start_bundle
self.counter = random.randint(0, self.count - 1)
TypeError: unsupported operand type(s) for -: 'AsSingleton' and 'int' [while running 'output VALIDATION to tfrecords/Write/WriteImpl/ParDo(_RoundRobinKeyFn)']
我在PTransform的類定義中看到了這一行
# By default, transforms don't have any side inputs.
side_inputs = ()
是否可以將側輸入傳遞給PTransforms? 謝謝您的幫助
WriteToTFRecord
不支持對num_shards
使用側輸入。 理論上沒有什么能阻止它這樣做(並且在Java SDK中是可能的),它只是沒有在Python SDK中實現。 隨意提交JIRA 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.