download mnist datas

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('/tmp/data/', one_hot=True)
WARNING:tensorflow:From <ipython-input-5-e0ce8097d3d7>:2: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From /Users/teddylee/miniconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From /Users/teddylee/miniconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-images-idx3-ubyte.gz
WARNING:tensorflow:From /Users/teddylee/miniconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From /Users/teddylee/miniconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From /Users/teddylee/miniconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
X_train = mnist.train.images
y_train = mnist.train.labels
X_train.shape, y_train.shape
((55000, 784), (55000, 10))
# parameters
learning_rate = 0.01
batch_size = 100
training_epochs = 25
X = tf.placeholder(tf.float32, shape=[None, 784])
Y = tf.placeholder(tf.float32, shape=[None, 10])

W = tf.Variable(tf.random_normal([784, 10]), name='weight')
b = tf.Variable(tf.random_normal([10]), name='bias')
hypothesis = tf.nn.softmax(tf.matmul(X, W) + b)
cost = tf.reduce_mean(-tf.reduce_sum(Y * tf.log(hypothesis), reduction_indices=1))
train = tf.train.GradientDescentOptimizer(learning_rate=learning_rate).minimize(cost)
cost_scalar = tf.summary.scalar('cost', cost)
W_hist = tf.summary.histogram('W', W)
summaries = tf.summary.merge_all()
summary_writer = tf.summary.FileWriter('logs/03_logistic_regression_with_mnist_dataset', sess.graph)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for epoch in range(training_epochs):
        total_batch = int(mnist.train.num_examples / batch_size)
        avg_cost = 0
        for i in range(total_batch):
            batch_x, batch_y = mnist.train.next_batch(batch_size)
            _, cost_, summary_ = sess.run([train, cost, summaries], feed_dict={X: batch_x, Y: batch_y})
            avg_cost += cost_ / total_batch
        print(avg_cost)
        summary_writer.add_summary(summary_, global_step=epoch)
    prediction = tf.equal(tf.argmax(hypothesis, 1), tf.argmax(Y, 1))
    accuracy = tf.reduce_mean(tf.cast(prediction, tf.float32))
    acc = accuracy.eval({X: mnist.test.images[:3000], Y: mnist.test.labels[:3000]})
    print("Accuracy: ", acc)
7.914185377467768
4.781445711309255
3.4321453462947495
2.695776921619069
2.2531482007286776
1.9645995258201252
1.7632157213037667
1.614504184181039
1.5002545454285359
1.4092625564878631
1.3348929220979873
1.2729112621870922
1.2201757449453532
1.1746131080389028
1.13468996757811
1.0994269660928035
1.0678009817275131
1.0392743049426507
1.0135599096254868
0.9897475153207772
0.9682238452001045
0.948097512180156
0.9296129375696183
0.9123521485653793
0.8962056561220775
Accuracy:  0.788