第一次运行 tensorflow的keras demo,发现loss不减少,精度不提高
$ python basic-classification.py
1.8.0
(60000, 28, 28)
Epoch 1/5
2018-07-24 13:36:01.051139: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
60000/60000 [==============================] - 3s 52us/step - loss: 14.5062 - acc: 0.1000
Epoch 2/5
60000/60000 [==============================] - 3s 51us/step - loss: 14.5063 - acc: 0.1000
Epoch 3/5
60000/60000 [==============================] - 3s 52us/step - loss: 14.5063 - acc: 0.1000
Epoch 4/5
60000/60000 [==============================] - 3s 51us/step - loss: 14.5063 - acc: 0.1000
Epoch 5/5
60000/60000 [==============================] - 3s 52us/step - loss: 14.5063 - acc: 0.1000
10000/10000 [==============================] - 0s 29us/step
修改激励函数relu 为sigmoid
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation=tf.nn.sigmoid),
keras.layers.Dense(10, activation=tf.nn.softmax)
])
原因:未明!
网友评论