初识Tensorflow1.0

初识Tensorflow

1. Ubuntu16.04下Tensorflow 1.0的安装

Tensorflow官方网站 中介绍了Tensorflow多种安装方法,包括基于 Docker 、基于 VirtualEnv 、基于源代码安装、基于二进制包在线安装等方法。

最初参照官方教程尝试了源码安装,下载各种依赖包花费数小时才成功;后来试了一下pip在线安装,才发现原来安装tensorflow可以分分钟搞定有木有:

$ pip install tensorflow-gpu  #支持gpu (安装该版本的前提是已经安装了 CUDA sdk,CUDA的安装和配置参照官网没有问题)

总之,强烈建议网速还可以的使用pip在线安装的方式,可以省去不少麻烦。

2. Tensorflow初体验

(1)尝试第一个tensorflow分类模型

进入目录 /tensorflow/examples/tutorials/mnist:

$ python mnist_softmax.py  # softmax cross entropy cost function

若tensorflow安装成功,则会出现如下结果:

Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
0.9202

这表示你的第一个分类器成功实现对MNIST数据集的分类,分类准确率
为 92.02% (准确率虽然不高,但我们的tensorflow总算运转起来了,也该高兴1秒钟…)

猜你喜欢

转载自blog.csdn.net/FlyingLittlePig/article/details/71075864