1

我在 Dataflow 上运行 Apache Beam 作业时遇到了一些问题。该代码在小型数据集上运行良好,但在 Dataflow 上运行更大的批处理作业时,我收到以下消息:

RuntimeError: InvalidArgumentError: indices[10925] = [889,43] is out of bounds: need 0 <= index < [1238,43] [[{{node transform/transform/SparseToDense}} = SparseToDense[T=DT_INT64, Tindices =DT_INT64, validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](transform/transform/StringSplit, transform/transform/SparseToDense/output_shape, transform/transform/compute_and_apply_vocabulary /apply_vocab/hash_table_Lookup、transform/transform/compute_and_apply_vocabulary/apply_vocab/string_to_index/hash_table/Const)]]

取自 Dataflow 中的日志。

我发现它连接到我的 AnalyzeAndTransformDataset 函数:

def preprocessing_fn(inputs):
      words = tf.string_split(inputs['tweet'],DELIMITERS)
      int_representation =tft.compute_and_apply_vocabulary(words,default_value=0,top_k=10000)
      # The shape out here is the problem, i think

      int_representation = 
      tft.sparse_tensor_to_dense_with_shape(int_representation, 
        [None,43])
      outputs = inputs
      outputs["int_representation"] = int_representation 
      return outputs

目标是为每个示例获得长度为 43 的密集输出向量。这将作为一个家庭项目用于 Twitter 数据的情感分析 :)

谢谢你的帮助!

更新:

我没有设法解决这个问题,而是在我的 Tensorflow 估计器模型中将向量转换为密集向量。不是我希望的解决方案,但它有效!也已将其报告给 GitHub 上的 Tensorflow 转换。

4

0 回答 0