title: mnist train and test accuracy only 0.49
body: <p>I am trying to implement the basic ANN on MNIST dataset, and I use the same code in tensorflow: <a href="https://www.tensorflow.org/tutorials/" rel="nofollow noreferrer">https://www.tensorflow.org/tutorials/</a>, but I get very low accuracy on training and testing dataset. I can't see what cause the problem. below is the output:</p>
  
  <pre><code>    2018-11-26 11:55:02.526281: I 
  tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports 
  instructions that this TensorFlow binary was not compiled to use: AVX2 
  FMA
  Epoch 1/10
     32/7000 [..............................] - ETA: 1:12 - loss: 1.4159 
  - acc: 0.4062
   960/7000 [===&gt;..........................] - ETA: 2s - loss: 1.1616 - 
  acc: 0.4052  
  1920/7000 [=======&gt;......................] - ETA: 1s - loss: 1.0438 - 
  acc: 0.4297
  2816/7000 [===========&gt;..................] - ETA: 0s - loss: 1.0004 - 
  acc: 0.4592
  3712/7000 [==============&gt;...............] - ETA: 0s - loss: 0.9788 - 
  acc: 0.4749
  4448/7000 [==================&gt;...........] - ETA: 0s - loss: 0.9691 - 
  acc: 0.4795
  5408/7000 [======================&gt;.......] - ETA: 0s - loss: 0.9602 - 
  acc: 0.4741
  6368/7000 [==========================&gt;...] - ETA: 0s - loss: 0.9567 - 
  acc: 0.4763
  7000/7000 [==============================] - 1s 105us/step - loss: 
  0.9543
  acc: 0.4773
  .................(I omitted some of the outputs, because they are almost the same.)
  
  Epoch 10/10
    32/7000 [..............................] - ETA: 0s - loss: 0.9383 - 
  acc: 0.5000
   896/7000 [==&gt;...........................] - ETA: 0s - loss: 0.9201 - 
  acc: 0.5022
  1696/7000 [======&gt;.......................] - ETA: 0s - loss: 0.9120 - 
  acc: 0.5083
  1984/7000 [=======&gt;......................] - ETA: 0s - loss: 0.9153 - 
  acc: 0.5055
  2560/7000 [=========&gt;....................] - ETA: 0s - loss: 0.9210 - 
  acc: 0.5043
  3328/7000 [=============&gt;................] - ETA: 0s - loss: 0.9208 - 
  acc: 0.5072
  4096/7000 [================&gt;.............] - ETA: 0s - loss: 0.9199 - 
  acc: 0.5054
  4672/7000 [===================&gt;..........] - ETA: 0s - loss: 0.9235 - 
  acc: 0.4991
  5344/7000 [=====================&gt;........] - ETA: 0s - loss: 0.9219 - 
  acc: 0.5011
  6144/7000 [=========================&gt;....] - ETA: 0s - loss: 0.9240 - 
  acc: 0.4977
  7000/7000 [==============================] - 1s 75us/step - loss: 
  0.9235 
  acc: 0.4946
  32/3000 [..............................] - ETA: 8s
  1920/3000 [==================&gt;...........] - ETA: 0s
  3000/3000 [==============================] - 0s 54us/step
  Test accuracy: 0.49966666666666665
  </code></pre>
  
  <hr>
  
  <p>I just use the code below, that is from that website:<a href="https://www.tensorflow.org/tutorials/" rel="nofollow noreferrer">https://www.tensorflow.org/tutorials/</a>. The dataset is MNIST.</p>
  
  <pre><code>import tensorflow as tf
  
  mnist = tf.keras.datasets.mnist
  
  (x_train, y_train), (x_test, y_test) = mnist.load_data()
  
  x_train, x_test = x_train / 255.0, x_test / 255.0
  
  model = tf.keras.models.Sequential([
      tf.keras.layers.Flatten(),
      tf.keras.layers.Dense(512, activation=tf.nn.relu),
      tf.keras.layers.Dropout(0.2),
      tf.keras.layers.Dense(10, activation=tf.nn.softmax)
  ])
  
  model.compile(optimizer='adam',
                loss='sparse_categorical_crossentropy',
                metrics=['accuracy'])
  
  model.fit(x_train, y_train, epochs=5)
  
  model.evaluate(x_test, y_test)
  </code></pre>
  
  <p>Actually, I just tried the code on google colab, and the result is normal:</p>
  
  <pre><code>Epoch 1/1
  60000/60000 [==============================] - 16s 270us/step - loss: 0.2015 - acc: 0.9406
  10000/10000 [==============================] - 1s 61us/step
  [0.11236203697770834, 0.9653]
  </code></pre>
  
  <p>Now I assume that this problem is caused by my computer, which is Macbook early 2015, and the OS is Mac OS X 10.14.1.</p>