Last answered:

29 Jun 2021

Posted on:

27 Apr 2021

1

Importing MNIST dataset - Deeper Example

After running the first part of the code I get this error:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-917aabef6fe5> in <module>
      1 import numpy as np
      2 import tensorflow as tf
----> 3 from tensorflow.examples.tutorials.mnist import input_data
      4 
      5 # TensorFLow includes a data provider for MNIST that we'll use.

ModuleNotFoundError: No module named 'tensorflow.examples'

I searched it online and found that in tensorflow documentation, it is recommended doing it in  this way:

builder = tfds.load(name="mnist")
builder.download_and_prepare()
mnist = builder.as_dataset(split='train', shuffle_files=True)

But then I get this error

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-2bcf21631d35> in <module>
      1 import numpy as np
      2 import tensorflow as tf
----> 3 import tensorflow_datasets as tfds
      4 
      5 #from tensorflow.examples.tutorials.mnist import input_data

ModuleNotFoundError: No module named 'tensorflow_datasets'

Any ideas ?

Thanks in advance.

1 answers ( 0 marked as helpful)
Posted on:

29 Jun 2021

0

Just replace the last two lines of the code. I searched Github and this solution worked for me:

mnist = tf.keras.datasets.mnist

Submit an answer