Я пытаюсь реализовать базовый ANN для набора данных MNIST, и я использую тот же код в тензорном потоке: https://www.tensorflow.org/tutorials/,, но я получаю очень низкую точность при обучении и тестировании набора данных.Я не вижу, в чем причина проблемы.ниже вывод:
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 [===>..........................] - ETA: 2s - loss: 1.1616 -
acc: 0.4052
1920/7000 [=======>......................] - ETA: 1s - loss: 1.0438 -
acc: 0.4297
2816/7000 [===========>..................] - ETA: 0s - loss: 1.0004 -
acc: 0.4592
3712/7000 [==============>...............] - ETA: 0s - loss: 0.9788 -
acc: 0.4749
4448/7000 [==================>...........] - ETA: 0s - loss: 0.9691 -
acc: 0.4795
5408/7000 [======================>.......] - ETA: 0s - loss: 0.9602 -
acc: 0.4741
6368/7000 [==========================>...] - 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 [==>...........................] - ETA: 0s - loss: 0.9201 -
acc: 0.5022
1696/7000 [======>.......................] - ETA: 0s - loss: 0.9120 -
acc: 0.5083
1984/7000 [=======>......................] - ETA: 0s - loss: 0.9153 -
acc: 0.5055
2560/7000 [=========>....................] - ETA: 0s - loss: 0.9210 -
acc: 0.5043
3328/7000 [=============>................] - ETA: 0s - loss: 0.9208 -
acc: 0.5072
4096/7000 [================>.............] - ETA: 0s - loss: 0.9199 -
acc: 0.5054
4672/7000 [===================>..........] - ETA: 0s - loss: 0.9235 -
acc: 0.4991
5344/7000 [=====================>........] - ETA: 0s - loss: 0.9219 -
acc: 0.5011
6144/7000 [=========================>....] - 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 [==================>...........] - ETA: 0s
3000/3000 [==============================] - 0s 54us/step
Test accuracy: 0.49966666666666665
Я просто использую код ниже, то есть с этого сайта: https://www.tensorflow.org/tutorials/. Набор данных - MNIST.
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)
На самом деле, я только что попробовал код на Google Colab, и результат нормальный:
Epoch 1/1
60000/60000 [==============================] - 16s 270us/step - loss: 0.2015 - acc: 0.9406
10000/10000 [==============================] - 1s 61us/step
[0.11236203697770834, 0.9653]
Теперь я предполагаю, что эта проблема вызвана моим компьютером, который является Macbook в начале 2015 года, и ОС Mac OSX 10.14.1.