【发布时间】:2021-05-24 07:49:06
【问题描述】:
我正在尝试从这里对 tensorflow 图像数据集(例如 cifar 和其他数据集)进行一些扩充: https://www.tensorflow.org/datasets/catalog/
现在我有一个映射函数,实际上来自 SO 的另一个用户帮助我使用了我自己的数据集:
def map_data(inputs):
image = inputs['image']
image = tf.numpy_function(func=aug_fn, inp=[image], Tout=tf.float32)
image = image / 255.0
labels = inputs['label']
labels = tf.one_hot(labels, num_classes)
return {'image_input': image, 'label': labels}, labels
现在在迭代数据集时出现此错误:
ValueError: Missing data for input "image_input". You passed a data dictionary with keys ['image', 'label']. Expected the following keys: ['image_input', 'label']
这是有道理的,因为解码器返回 uint8 类型。
但我在文档中找不到有关如何更改它的任何信息或示例。
我能以某种方式访问解码器对象的属性吗?
我在 API 中尝试过 https://www.tensorflow.org/datasets/api_docs/python/tfds/decode/Decoder?hl=cs
但它不起作用。
非常感谢您!
【问题讨论】:
标签: tensorflow keras tensorflow-datasets