简介
本文介绍了在Ubuntu下如何手动下载mnist.npz数据集并且放到指定位置供tensorflow使用。
tensorflow版本:2.3
解决办法
先写解决办法:
- 下载,百度网盘下载链接https://pan.baidu.com/s/1jH6uFFC 密码: dw3d。不是我的网盘,感谢这位大哥的写的博文以及其中的网盘连接。
- 下载完成之后放到
~/.keras/dataset/
目录下,命名为mnist.npz
完成。
解决过程
在使用tensorflow的加载mnist的时候,发现需要从https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
这个网址下载,一看这个域名就不可能成功嘛!
想着我看看能不能把我之前下好的mnist数据集用上,于是看了下加载mnist数据集的源码,如下:
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""MNIST handwritten digits dataset.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.keras.utils.data_utils import get_file
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.datasets.mnist.load_data')
def load_data(path=