【发布时间】:2020-07-28 01:49:59
【问题描述】:
这是我的代码,我不知道为什么它给了我 0.3% 的准确率
谁能告诉我这段代码有什么问题?
def train_mnist():
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(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
history = model.fit(x_train, y_train, epochs=5)
return history.epoch, history.history['acc'][-1]
train_mnist()
感谢提前
【问题讨论】:
-
我想这不是您所关心的,但它可能对某人有所帮助:卷积神经网络将是这里的最佳选择。
标签: python tensorflow keras