【发布时间】:2019-05-20 23:28:28
【问题描述】:
当我尝试训练我建立的模型时,我发现损失和准确率并没有改变。
import tensorflow as tf
tf.enable_eager_execution()
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer=tf.train.AdamOptimizer(),
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=5)
这是结果:
Epoch 1/5 60000/60000 [==============================] - 7s 123us/sample - loss: 12.9310 - acc: 0.1975
Epoch 2/5 60000/60000 [==============================] - 5s 87us/sample - loss: 12.8994 - acc: 0.1997
Epoch 3/5 60000/60000 [==============================] - 5s 85us/sample - loss: 12.9162 - acc: 0.1986
Epoch 4/5 60000/60000 [==============================] - 5s 84us/sample - loss: 12.9052 - acc: 0.1993
Epoch 5/5 60000/60000 [==============================] - 5s 84us/sample - loss: 12.9052 - acc: 0.1993
【问题讨论】:
标签: tensorflow