I have tried lots of times by taking many ways but it doesn't work anyway.
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_dataput_data
I have tried lots of times by taking many ways but it doesn't work anyway.
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_dataput_data
If you want to load MNIST dataset, you can try this:
import tensorflow as tf
import matplotlib.pyplot as plt
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
fig, axes = plt.subplots(2,5,figsize=(15,6))
for idx, axe in enumerate(axes.flatten()):
axe.axis('off')
axe.set_title(f'label : {y_train[idx]}')
axe.imshow(x_train[idx])
plt.show()
Or you can use tensorflow_datasets like below:
import tensorflow_datasets as tfds
import matplotlib.pyplot as plt
dataset = tfds.load('mnist', download=True, as_supervised=True, split = 'train').batch(10)
image, label = next(iter(dataset))
fig, axes = plt.subplots(2,5,figsize=(15,6))
for idx, axe in enumerate(axes.flatten()):
axe.axis('off')
axe.set_title(f'label : {label[idx]}')
axe.imshow(image[idx][...,0])
plt.show()
Output:
In in tensorflow 2, you don't need turorial package, use:
tf.keras.datasets.mnist.load_data(
path='mnist.npz'
)
You can read more : here