如何识别张量流数据集中的列?

时间:2019-04-16 15:07:57

标签: python tensorflow deep-learning tensorflow-datasets

这两个数据集有什么区别:

  1. dataset1 = _OptionsDataset shapes: {image: (28, 28, 1), label: ()}, types: {image: tf.uint8, label: tf.int64}
  2. dataset2 = _OptionsDataset shapes: ((28, 28, 1), ()), types: (tf.uint8, tf.int64)
    对于功能
def convert_types(image, label):
  image = tf.cast(image, tf.float32)
  image /= 255
  return image, label

我可以做dataset2.map(convert_types),但不能做dataset1.map(convert_types)。 对于数据集1,我需要:

def convert_types_new(record):
  record['image'] = tf.cast(record['image'], tf.float32)
  record['image'] /= 255
  return record['image'], record['label']

我正在使用TF-V2。谢谢!

0 个答案:

没有答案