我正在使用MNIST数据集学习TensorFlow和神经网络。以下是我的Python代码。
我的准确率在9%到13%之间,无法超过这个范围。我认为我已经正确地实现了代码,但无法找出问题所在。我发现的一个问题是,模型只正确预测了0。
回答:
我在计算网络的输出时犯了错误,
错误的:
output = tf.add(tf.matmul( l3, output_layer['weights']), output_layer['biases'])output = tf.nn.relu(output)
正确的:
output = tf.add(tf.matmul( l3, output_layer['weights']), output_layer['biases'])
我再次归一化了输出,这搞乱了整个网络。发布这个答案,因为它将来可能会对某人有帮助。谢谢!
附注:借用了sentdex的代码
编辑:
我发现通过使用卷积神经网络(CNN)可以进一步提高准确率,使用循环神经网络(RNN)可以进一步提高。可能有人会发现这有用。