英文:
Error ! MNIST.npz is not UTF-8 encoded error saving disabled
问题
当我想在Jupyter中加载MNIST.npz格式的数据集时,我使用以下代码来加载文件,但出现了以下错误,显示我的文件不存在:[FileNotFoundError: [Errno 2] No such file or directory: 'MNIST_data/mnist.npz']。当我从我的文件中检查它并尝试打开它时,出现了另一个错误,提示mnist.npz不是UTF-8编码,保存被禁用了。
我该如何修复它?请帮助我。
我在Jupyter中的代码:
import numpy as np
path = "MNIST_data/mnist.npz"
with np.load(path, allow_pickle=True) as f:
print(type(f))
x_train, y_train = f['x_train'], f['y_train']
x_test, y_test = f['x_test'], f['y_test']
英文:
When I want to load the MNIST.npz dataset with this format (mnist. npz) in Jupyter; I use from below codes to load the file but this error appeared that showed my file does not exist [FileNotFoundError: [Errno 2] No such file or directory: 'MNIST_data/mnist.npz'].
When I checked it from my files and tried to open it, another error appeared that said mnist.npz is not UTF-8 encoded saving disabled.
How can I fix it? Help me pls.
My codes in Jupyter:
import numpy as np
path = "MNIST_data/mnist.npz"
with np.load(path, allow_pickle=True) as f:
print(type(f))
x_train, y_train = f\['x_train'\], f\['y_train'\]
x_test, y_test = f\['x_test'\], f\['y_test'\]
答案1
得分: 0
The MNIST.npz dataset with npz format is not UTF-8 encoding and for that reason, I couldn't load it with the codes which I shared in my question box. But finally, I found the solution; If you want to solve the error you should use 'ASCII' encoding like the below codes:
import numpy as np
path = "File address in your system"
with np.load(path, allow_pickle=True, encoding='ASCII' ) as f:
print(type(f))
x_train, y_train = f['x_train'], f['y_train']
x_test, y_test = f['x_test'], f['y_test']
Good luck
英文:
The MNIST.npz dataset with npz format is not UTF-8 encoding and for that reason, I couldn't load it with the codes which I shared in my question box. But finally, I found the solution; If you want to solve the error you should use 'ASCII' encoding like the below codes:
import numpy as np
path = "File address in your system"
with np.load(path, allow_pickle=True, encoding='ASCII' ) as f:
print(type(f))
x_train, y_train = f\['x_train'\], f\['y_train'\]
x_test, y_test = f\['x_test'\], f\['y_test'\]
Good luck
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论