gpt4 book ai didi

python - 模块未找到错误 : No module named 'mnist'

转载 作者:行者123 更新时间:2023-12-05 05:07:49 33 4
gpt4 key购买 nike

我正在尝试将语言环境 MNIST 数据集从我的计算机导入 Jupyter Notebook,但出现 ModuleNotFound 错误。

我已经安装了 python-mnist 包

# Import necessary modules 
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
from mnist import MNIST

import numpy as np
import matplotlib.pyplot as plt

mnist = MNIST('../Dataset/MNIST')
x_train, y_train = mnist.load_training() #60000 samples
x_test, y_test = mnist.load_testing() #10000 samples

THE ERROR MESSAGE
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-4e881af1c89c> in <module>
2 from sklearn.neighbors import KNeighborsClassifier
3 from sklearn.model_selection import train_test_split
----> 4 from mnist import MNIST
5
6 import numpy as np

ModuleNotFoundError: No module named 'mnist'

最佳答案

尝试使用:

import tensorflow_datasets as tfds
datasets = tfds.load('mnist')

train_dataset = datasets['train']
test_dataset = datasets['test']

IMAGE_INPUT_NAME = 'image'
LABEL_INPUT_NAME = 'label'

https://www.tensorflow.org/datasets/overview

关于python - 模块未找到错误 : No module named 'mnist' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58817824/

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