This blog is mainly for myself. But if it helps you, I’ll be happy of course.
Before everything, let me drop some useful links here.
乙 - The MNIST database by Yann LeCun
Other useful and interesting links:
Tensorflow 学习笔记:Mnist 手写训练集调试,准确率变为0.1的解决办法及如何将准确率调高到98%以上
Tensorflow的MNIST进阶,准确率提升情况,最终训练一万次,准确率达到99.28%,可以说比官方的效果还要好
1. Installation & Download
1.1 Tensorflow Installation
参照链接甲,首先你需要安好Python 2.7,因为TensorFlow Python API依赖于Python 2.7。此外,我还没有试过开启GPU支持。
链接甲中的教程给出了安装TensorFlow 0.5.0的命令,而它后面的MNIST教程在TensorFLow 0.5.0上会出如下错误
Traceback (most recent call last):
File "exercise.py", line 5, in <module>
from tensorflow.examples.tutorials.mnist import input_data
ImportError: No module named examples.tutorials.mnist
解决方法是把TensorFlow更新到0.9.0版本:
pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
pip install --upgrade tensorflow
注意不要简单地用上面的update去更新TensorFlow。因为今天(2020.0221)TensorFlow已经到了2.1.0,而我在用这个版本的TensorFLow时会出现下面这个问题,具体原因尚不明确。在网上找了一圈解决方法,结果大家都说是要升级到0.9.0,所以我只能把2.1.0的TensorFlow“升级”成0.9.0的。
Traceback (most recent call last):
File "exercise.py", line 5, in <module>
from tensorflow.examples.tutorials.mnist import input_data
ImportError: No module named tutorials.mnist
1.2 Important Documents Download
TensorFlow是Google开发的,所以如果你用TensorFlow中文社区的MNIST数据下载页面上的链接下载东西,很有可能会遇到下载不了的情况。好在这个页面上还贴出了所用到的数据集的网址,见链接乙。自己手动下载下来就好了。
2. MNIST Introduction for beginners
链接丙是个很好的入门材料,讲得很细致。就是有一点需要注意,他所给出的导入数据的代码有些问题。解决方法是下面的两行换成下下面的两行,并配合TensorFLow 0.9.0使用。
import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
< < -- 替换 -- > >
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
剩下的事情,就是照着链接丙自己好好学习一遍了。网上关于TensorFlow的教程也有很多,可以自己挖掘挖掘。链接丁中有官方的教程代码,链接戊也需要好好挖掘挖掘。
Have fun,
Fin