import input_data MNIST tensorflow not working

前端 未结 15 1528
感情败类
感情败类 2020-12-09 14:44

TensorFlow MNIST example not running with fully_connected_feed.py

I checked this out and realized that input_data was not built-in. So I downloaded the

相关标签:
15条回答
  • 2020-12-09 15:21

    I might be kinda late, but for tensorflow version 0.12.1, you might wanna use input_data.read_data_sets instead.

    Basically using this function to load the data from your local drive that you had downloaded from http://yann.lecun.com/exdb/mnist/.

    from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('data_set/')

    0 讨论(0)
  • 2020-12-09 15:21

    If you're using Tensorflow 2.0 or higher, you need to install tensorflow_datasets first:

    pip install tensorflow_datasets
    

    or if you're using an Anaconda distribution:

    conda install tensorflow_datasets
    

    from the command line.

    If you're using a Jupyter Notebook you will need to install and enable ipywidgets. According to the docs (https://ipywidgets.readthedocs.io/en/stable/user_install.html) using pip:

    pip install ipywidgets
    jupyter nbextension enable --py widgetsnbextension
    

    If you're using an Anaconda distribution, install ipywidgets from the command line like such:

    conda install -c conda-forge ipywidgets
    

    With the Anaconda distribution there is no need to enable the extension, conda handles this for you.

    Then import into your code:

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

    You should be able to use it without error if you follow these instructions.

    0 讨论(0)
  • 2020-12-09 15:22

    There's now a much easier way to load MNIST data into tensorflow without having to download the data by using Tensorflow 2 and Tensorflow Datasets

    To get started, make sure you import Tensorflow and specify the 2nd version:

    %tensorflow_version 2.x
    import tensorflow as tf
    

    Then load the data into a dictionary using the following code:

    MNIST_data = tfds.load(name = "mnist")
    

    and Then split the data into train and test:

    train, test = MNIST_data['train'] , MNIST_data['test']
    

    Now you can use these data generators however you like.

    0 讨论(0)
  • 2020-12-09 15:23

    As TensorFlow official website shown, All MNIST data is hosted on http://yann.lecun.com/exdb/mnist/

    0 讨论(0)
  • 2020-12-09 15:23

    Remove the lines:

    from tensorflow.examples.tutorials.mnist import input_data
    fashion_mnist = input_data.read_data_sets('input/data',one_hot=True)
    

    and the line below will suffice:

    fashion_mnist = keras.datasets.fashion_mnist
    

    Note that if the dataset is not available in the examples built-in to the keras, this will download the dataset and solve the problem. :)

    0 讨论(0)
  • 2020-12-09 15:24

    For TensorFlow API 2.0 the mnist data changed place to: tf.keras.datasets.mnist.load_data

    0 讨论(0)
提交回复
热议问题