ValueError: Индекс вне диапазона с использованием входного значения dim 0 при использовании функции карты набора данных tenorflow - PullRequest
0 голосов
/ 08 июля 2019

Я хочу создать набор данных 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>.\
...