Warning: Please use alternatives such as official/mnist/dataset.py from tensorflow/models

tensorflow.examples.tutorials is now deprecated and it is recommended to use tensorflow.keras.datasets as follows:

import tensorflow as tf
mnist = tf.keras.datasets.mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()

https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist/load_data


You can use tf.logging module like this:

import numpy as np

import tensorflow as tf
old_v = tf.logging.get_verbosity()
tf.logging.set_verbosity(tf.logging.ERROR)

from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
train_data = mnist.train.images  # Returns np.array
train_labels = np.asarray(mnist.train.labels, dtype=np.int32)
eval_data = mnist.test.images  # Returns np.array
eval_labels = np.asarray(mnist.test.labels, dtype=np.int32)

tf.logging.set_verbosity(old_v)