【问题标题】:Access 'coarse_label' in CIFAR-100 loaded from tensorflow_datasets访问从 tensorflow_datasets 加载的 CIFAR-100 中的“coarse_label”
【发布时间】:2019-10-23 12:58:29
【问题描述】:

我正在使用 tensorflow_datasets (tfds doc) 加载 CIFAR-100

train, test = tfds.load(name="cifar100:3.*.*", split=["train", "test"], as_supervised=True)

CIFAR-100 既有标签(100 类)也有粗略标签(20 类),如上面链接的文档中所示。访问标签很容易,例如:

for image, label in train:
     # ... the label here is the actual label, not the coarse_label

但是,我计划基于粗略标签进行操作,例如,通过它进行过滤或将其用作 Keras 分类器中的标签。

如何访问粗略标签?

【问题讨论】:

    标签: python tensorflow keras tensorflow-datasets


    【解决方案1】:

    我找到了解决方案。如果我不按监督方式加载,即如果我删除 as_supervised=True

    train, test = tfds.load(name="cifar100:3.*.*", split=["train", "test"])
    

    ,我可以从字典中获取粗略标签,例如

    for item in train:
       print(item['coarse_label'])
    

    这样,我将能够对数据集 s.t. 进行重构。粗略标签可用于分类。但是,即使我对标签感兴趣,我也必须加载 as_supervised=False 对我来说仍然看起来很不自然。如果有人有更好的解决方案,我很乐意接受这个答案。

    【讨论】:

      猜你喜欢
      • 2017-10-09
      • 2020-12-11
      • 2019-08-23
      • 1970-01-01
      • 2017-12-19
      • 2020-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多