chiphuyen / stanford-tensorflow-tutorials

This repository contains code examples for the Stanford's course: TensorFlow for Deep Learning Research.
http://cs20.stanford.edu
MIT License
10.32k stars 4.32k forks source link

03_logreg.py- My Jupyter notebook couldn't download the MNIST file. #135

Open frankburg opened 5 years ago

frankburg commented 5 years ago

I ran the 03_logreg.py file but it couldn't download the MNIST file. Look at the error it throws below, what could be the cause.

Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-9-f61291f4ea9e> in <module>()
     17 # Step 1: Read in data
     18 mnist_folder = 'data/mnist'
---> 19 download_mnist(mnist_folder)
     20 train, val, test = read_mnist(mnist_folder, flatten=True)
     21 

<ipython-input-8-c749e6c8ff57> in download_mnist(path)
     82         download_url = os.path.join(url, filename)
     83         local_dest = os.path.join(path, filename)
---> 84         download_one_file(download_url, local_dest, byte, True)
     85 
     86 def parse_data(path, dataset, flatten):

<ipython-input-8-c749e6c8ff57> in download_one_file(download_url, local_dest, expected_byte, unzip_and_remove)
     54     else:
     55         print('Downloading %s' %download_url)
---> 56         local_file, _ = urllib.request.urlretrieve(download_url, local_dest)
     57         file_stat = os.stat(local_dest)
     58         if expected_byte:

~/anaconda3/envs/tensorflow_p36/lib/python3.6/urllib/request.py in urlretrieve(url, filename, reporthook, data)
    256         # Handle temporary file setup.
    257         if filename:
--> 258             tfp = open(filename, 'wb')
    259         else:
    260             tfp = tempfile.NamedTemporaryFile(delete=False)

FileNotFoundError: [Errno 2] No such file or directory: 'data/mnist/train-images-idx3-ubyte.gz'
MartinAbilev commented 5 years ago
  1. do directory data/mnist/ exist ??
  2. do file train-images-idx3-ubyte.gz is there ???
  3. in case not maybe try to place it there manually and repeat to check if there problem with download or problem with path to file after download.
XuanxuanGao commented 5 years ago

I met the same error, and I resolved it. You have to creat the directory data/mnist/ manully on your disk.

LiUzHiAn commented 5 years ago

The reason why you meet this issue is you are using Windows OS. Just find out where we defined the file path, and modify the “train-images-idx3-ubyte” to “train-images.idx3-ubyte”