【发布时间】:2020-03-16 18:51:13
【问题描述】:
假设我有一个 32*32*3 类型图像的数据集作为源数据:
<DatasetV1Adapter shapes: {coarse_label: (), image: (32, 32, 3), label: ()}, types: {coarse_label: tf.int64, image: tf.uint8, label: tf.int64}>
序列化后得到的数据:
<MapDataset shapes: {depth: (), height: (), image_raw: (), label: (), width: ()}, types: {depth: tf.int64, height: tf.int64, image_raw: tf.string, label: tf.int64, width: tf.int64}>
我可以使用这段代码访问每个元素:
for i in parsed_image_dataset.take(1):
j=i['image_raw']
array_shape = e1['image'].numpy().shape
print(np.frombuffer(j.numpy(), dtype = 'uint8').reshape(array_shape))
其中e1 是在原始数据集中使用get_next 生成的。因此,正如预期的那样,打印会打印与预序列化相同的图像。但是,我可以以某种方式转换我的序列化数据集,而不是逐个元素地执行此操作马上变成原来的uint8一个?
【问题讨论】:
-
“立即”是什么意思?将所有内容加载到内存中?这通常不是一个好主意。也许分批可以吗?
-
能否提供可重现的代码来生成示例序列化数据集
标签: python tensorflow machine-learning