【问题标题】:How to unpickle CIFAR-10, load batches and split datasets?如何解开 CIFAR-10、加载批次和拆分数据集?
【发布时间】:2019-08-23 06:28:11
【问题描述】:

使用卷积神经网络进行 CIFAR-10 数据集分类。我无法理解:

1) 提取 CIFAR-10 数据集文件的位置 2)如何使用pickle框架加载批次 3) 将数据集拆分为训练数据和测试数据

请帮助代码,在 jupyter notebook 上使用 python 3.6。

我试过了,但似乎没有任何效果。可能是因为我将 CIFAR-10 文件保存在错误的位置。

def unpickle(file):
    import pickle
    with open(file, 'rb') as fo:
        dict = pickle.load(fo, encoding='bytes')
    return dict

【问题讨论】:

  • 您的问题究竟是什么? “似乎没有任何效果”几乎不能提供任何信息
  • 上面的代码没有加载 CIFAR-10 数据集。我很困惑在哪里使用pickle提取文件以进行上传以及代码行“def unpickle(file)”中的“文件”是什么意思?

标签: python-3.x machine-learning conv-neural-network pickle upickle


【解决方案1】:

您可以尝试使用 keras 数据集加载数据:

from keras.datasets import cifar10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()

文档是 here 。 它应该可以帮助您解决所有 3 个问题,因为 keras 会为您处理一切。

【讨论】:

  • 我实际上只需要使用pickle来加载数据集。 python 3 这个链接中的代码对我不起作用:cs.toronto.edu/~kriz/cifar.html 我想是因为在上传之前我不知道在哪里保存 CIFAR-10 文件。
猜你喜欢
  • 2017-12-19
  • 1970-01-01
  • 2022-12-04
  • 2017-12-20
  • 2021-08-29
  • 2018-06-22
  • 2015-11-13
  • 2020-10-14
  • 1970-01-01
相关资源
最近更新 更多