gpt4 book ai didi

python - 将 MNIST 数据与 Keras 结合使用

转载 作者:太空宇宙 更新时间:2023-11-04 04:08:39 26 4
gpt4 key购买 nike

我目前正在研究 MNIST 数据,作为使用 numpy 和 tensorflow 类(class)的一部分。我正在运行他们在类(class)中提供的代码,在运行这段代码时我注意到来自 tensorflow 的一些警告:

from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets("../data/mnist_data/", one_hot=True)

我查看了文档并了解到这已被弃用,应该改用 keras 中的 MNIST。所以我把上面的代码改成了这样

from keras.datasets import mnist
from keras.models import Sequential, load_model
from keras.layers.core import Dense, Dropout, Activation
from keras.utils import np_utils

(X_train, y_train), (X_test, y_test) = mnist.load_data()

我现在的问题是,他们在类(class) Material 中使用了这个功能:

training_digits, training_labels = mnist.train.next_batch(5000)

该函数 next_batch() 不适用于 keras,并且原始 MNIST 数据集非常大。使用 keras 有解决这个问题的巧妙方法吗?

非常感谢!

最佳答案

您可以按照此处所述设置 batch_size 并使用一次迭代器 () Keras Mnist documentation

关于python - 将 MNIST 数据与 Keras 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56784811/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com