Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 'tensorflow.python.keras.datasets.fashion_mnist' has no attribute 'load_data'

I am currently following this intro tutorial on the Keras website: https://www.tensorflow.org/tutorials/keras/basic_classification

Several steps in I run into this error after calling fashion_mnist.load_data():

AttributeError: module 'tensorflow.python.keras.datasets.fashion_mnist' has no attribute 'load_data'

This is the full output:

Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> from tensorflow import keras
>>> fashion_mnist = keras.datasets.fashion_mnist
>>> (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow.python.keras.datasets.fashion_mnist' has no attribute 'load_data'

I'm using tensorflow 1.5.0, Keras 2.2.2, and Python 3.6.6.

Is tensorflow's tutorial outdated, or am I missing something? If I use the mnist set instead of fashion_mnist, it works with no problem. From this link https://www.tensorflow.org/api_docs/python/tf/keras/datasets/fashion_mnist it would seem that fashion_mnist does indeed have a function called load_data.

like image 872
Brendan Gregory Avatar asked Aug 03 '18 14:08

Brendan Gregory


People also ask

What is Load_data?

load_data() unpacks a dataset that was specifically pickled into a format that allows extracting the data as shown in the source code (also pre-sorted into train vs test, pre-shuffled, etc). Keras then returns the unpacked data in the form you used above. Follow this answer to receive notifications.

What does MNIST Load_data return?

Returns. Tuple of NumPy arrays: (x_train, y_train), (x_test, y_test) . x_train: uint8 NumPy array of grayscale image data with shapes (60000, 28, 28) , containing the training data. Pixel values range from 0 to 255.


1 Answers

The problem lies indeed in your Tensorflow version. The tutorial you link to uses version 1.9.0:

print(tf.__version__)
# 1.9.0

which does include a function load_data for fashion_mnist (docs). But this function is missing from your version, as you can see from the v1.5 docs.

like image 169
desertnaut Avatar answered Oct 01 '22 19:10

desertnaut