MNIST使用以下代码加载数据:
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
我已经准备好自定义数据集,并希望加载相同的数据集。因此,请尝试以下代码:
(train_images, train_labels), (test_images, test_labels) = (('C:\\Users\\sm50014\\Desktop\\new\\t10k-images-idx3-ubyte'),('C:\\Users\\sm50014\\Desktop\\new\\t10k-labels-idx1-ubyte')), (('C:\\Users\\sm50014\\Desktop\\new\\test-images-idx3-ubyte'),('C:\\Users\\sm50014\\Desktop\\new\\test-labels-idx1-ubyte'))
其中t10k-images-idx3-ubyte是自定义图像训练数据
t10k-labels-idx1-ubyte是自定义标签训练数据
test-images-idx3-ubyte是自定义图像测试数据
test-labels-idx1-ubyte是自定义标签测试数据
但是它将其另存为字符串在(train_images, train_labels), (test_images, test_labels)
中。
您能否以正确的方式帮助我将数据加载到
(train_images, train_labels), (test_images, test_labels)
?
答案 0 :(得分:2)
在您的示例中,您只是将字符串的元组分配给变量:
train_images = 'C:\\Users\\sm50014\\Desktop\\new\\t10k-images-idx3-ubyte'
train_labels = 'C:\\Users\\sm50014\\Desktop\\new\\t10k-labels-idx1-ubyte'
test_images = 'C:\\Users\\sm50014\\Desktop\\new\\test-images-idx3-ubyte'
test_labels = 'C:\\Users\\sm50014\\Desktop\\new\\test-labels-idx1-ubyte'
要加载自己的数据集,您应该创建自定义加载器以读取图像并将其馈送到您的网络。您可以在以下示例中查看这种加载器的示例:https://medium.com/@waleedka/traffic-sign-recognition-with-tensorflow-629dffc391a6(函数 load_data )。