【问题标题】:Tensorflow load dataset: UnimplementedError: Append(absl::Cord) is not implemented [Op:TakeDataset]Tensorflow 加载数据集:UnimplementedError: Append(absl::Cord) 未实现 [Op:TakeDataset]
【发布时间】:2021-05-02 03:09:58
【问题描述】:

我正在尝试使用 Tensorflow 2.4 从我的 Tensorflow 数据集中提取批次,但出现一个非常奇怪的错误:

--> 221         for batch, (input_seq, target_seq_in, target_seq_out) in enumerate(dataset.take(-1)):
    222             # Train and get the loss value
    223             loss, accuracy = train_step(input_seq, target_seq_in, target_seq_out, en_initial_states, optimizer)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py in take(self, count)
   1417       Dataset: A `Dataset`.
   1418     """
-> 1419     return TakeDataset(self, count)
   1420 
   1421   def skip(self, count):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py in __init__(self, input_dataset, count)
   3856         input_dataset._variant_tensor,  # pylint: disable=protected-access
   3857         count=self._count,
-> 3858         **self._flat_structure)
   3859     super(TakeDataset, self).__init__(input_dataset, variant_tensor)
   3860 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_dataset_ops.py in take_dataset(input_dataset, count, output_types, output_shapes, name)
   6608       return _result
   6609     except _core._NotOkStatusException as e:
-> 6610       _ops.raise_from_not_ok_status(e, name)
   6611     except _core._FallbackException:
   6612       pass

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   6860   message = e.message + (" name: " + name if name is not None else "")
   6861   # pylint: disable=protected-access
-> 6862   six.raise_from(core._status_to_exception(e.code, message), None)
   6863   # pylint: enable=protected-access
   6864 

/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)

UnimplementedError: Append(absl::Cord) is not implemented [Op:TakeDataset]

我的流程如下:

dataset = tf.data.Dataset.from_tensor_slices((encoder_inputs, decoder_inputs, decoder_targets))
dataset = dataset.batch(batch_size, drop_remainder=True)

tf.data.experimental.save(dataset, save_path + 'dataset_' + str(index))
...

dataset = tf.data.experimental.load(folder_path +'dataset_'+str(index), (tf.TensorSpec(shape=(MAX_LEN,), dtype=tf.int64, name=None), tf.TensorSpec(shape=(MAX_LEN,), dtype=tf.int64, name=None), tf.TensorSpec(shape=(MAX_LEN,), dtype=tf.int64, name=None)))

我不明白这个错误是从哪里来的,也找不到任何相关的东西。

【问题讨论】:

    标签: python-3.x tensorflow batch-processing tensorflow-datasets notimplementedexception


    【解决方案1】:

    您的堆栈跟踪似乎缺少触发错误的实际行,但我还是会尝试猜测。

    该错误似乎与将数据集写入已存在的文件有关,然后它尝试追加到该文件,但它用作 WritableFile 的任何内容都没有覆盖追加(请参阅:https://github.com/tensorflow/tensorflow/blob/516ae286f6cc796e646d14671d94959b129130a4/tensorflow/core/platform/file_system.h#L783

    继续疯狂猜测 - 如果这一行:

    tf.data.experimental.save(dataset, save_path + 'dataset_' + str(index))
    

    正在触发错误,尝试一些愚蠢的事情 - 更改文件名。

    【讨论】:

    • 非常感谢您的回复。你的猜测似乎是对的。我确实在覆盖一个文件。我从没想过这会导致任何问题。我会尽快接受答案并让它发挥作用
    猜你喜欢
    • 2019-07-10
    • 2022-06-17
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 2022-12-23
    • 2020-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多