ValueError:使用张量流数据集贴图功能时使用输入dim 0索引超出范围

时间:2019-07-08 15:04:44

标签: python tensorflow tensorflow-datasets

我想为图像和蒙版创建一个tfrecord数据集

filenames = tf.data.Dataset.list_files(local_pattern, seed=35155)
def decode_jpeg_and_label(filename):
    bits = tf.read_file(filename)
    image = tf.image.decode_jpeg(bits)
    bits_mask = tf.read_file("fdata/train_mask/{}png".format(filename[12:23]))
    mask = tf.image.decode_png(bits_mask)
    return image, mask

dataset1 = filenames.map(decode_jpeg_and_label, num_parallel_calls=AUTO)

具有以下输出:

InvalidArgumentError                      Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs)
   1658   try:
-> 1659     c_op = c_api.TF_FinishOperation(op_desc)
   1660   except errors.InvalidArgumentError as e:

InvalidArgumentError: Index out of range using input dim 0; input has only 0 dims for 'strided_slice' (op: 'StridedSlice') with input shapes: [], [1], [1], [1] and with computed input tensors: input[3] = <1>.

在处理上述异常期间,发生了另一个异常:

......

-> 1662     raise ValueError(str(e))
   1663 
   1664   return c_op

ValueError: Index out of range using input dim 0; input has only 0 dims for 'strided_slice' (op: 'StridedSlice') with input shapes: [], [1], [1], [1] and with computed input tensors: input[3] = <1>.\

0 个答案:

没有答案