如何加载自定义数据集以提供给 CNN?

How to load custom dataset for feeding to CNN?

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)?

在您的示例中,您只需将字符串元组分配给变量:

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 (function load_data).