环境:虚拟机安装的ubuntu16.04 LTS
参考官网 网址
**
检查系统自带Python版本:
xiaokai@ubuntu:~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
使用pip安装,pip是一个包管理系统,用于安装和管理Python软件包,注意我们的Python版本是Python3+,所有要安装对应的pip3.
xiaokai@ubuntu:~$ sudo apt-get install python3-pip python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-dev is already the newest version (2.7.11-1).
python3-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 292 not upgraded.
我这里已经安装过了,安装比较简单一路yes和enter
接着选择对应的tensorflow二进制文件安装,这里是虚拟机没有GPU选择CPU only版本# Ubuntu/Linux 64-bit, CPU only, Python 3.5
关联下载地址
xiaokai@ubuntu:~$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp35-cp35m-linux_x86_64.whl
下载安装:
xiaokai@ubuntu:~$ sudo pip3 install --upgrade $TF_BINARY_URL
The directory '/home/xiaokai/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/xiaokai/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You must give at least one requirement to install (see "pip help install")
当然我这里也是安装过了,下载如果遇到网速慢需要重复安装。。。
这里看到是3.5.2版本
测试过程:
查看安装路径
xiaokai@ubuntu:~$ python3 -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
/usr/local/lib/python3.5/dist-packages/tensorflow
进入该目录下执行自带测试用例
查看输出:
xiaokai@ubuntu:~$ cd /usr/local/lib/python3.5/dist-packages/tensorflow
xiaokai@ubuntu:/usr/local/lib/python3.5/dist-packages/tensorflow$ sudo python3 -m tensorflow.models.image.mnist.convolutional
训练过程:
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
Initialized!
Step 0 (epoch 0.00), 11.4 ms
Minibatch loss: 12.053, learning rate: 0.010000
Minibatch error: 90.6%
Validation error: 84.6%
Step 100 (epoch 0.12), 410.2 ms
Minibatch loss: 3.276, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 7.2%
Step 200 (epoch 0.23), 402.6 ms
Minibatch loss: 3.457, learning rate: 0.010000
Minibatch error: 14.1%
Validation error: 3.9%
Step 300 (epoch 0.35), 418.1 ms
Minibatch loss: 3.204, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 3.1%
Step 400 (epoch 0.47), 427.7 ms
Minibatch loss: 3.211, learning rate: 0.010000
Minibatch error: 9.4%
Validation error: 2.5%
Step 500 (epoch 0.58), 444.4 ms
Minibatch loss: 3.295, learning rate: 0.010000
Minibatch error: 7.8%
Validation error: 2.6%
Step 600 (epoch 0.70), 406.3 ms
Minibatch loss: 3.213, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 2.6%
Step 700 (epoch 0.81), 406.1 ms
Minibatch loss: 3.042, learning rate: 0.010000
Minibatch error: 3.1%
Validation error: 2.2%
Step 800 (epoch 0.93), 438.1 ms
Minibatch loss: 3.086, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 2.0%
Step 900 (epoch 1.05), 413.5 ms
Minibatch loss: 2.942, learning rate: 0.009500
Minibatch error: 3.1%
Validation error: 1.7%
Step 1000 (epoch 1.16), 421.4 ms
Minibatch loss: 2.846, learning rate: 0.009500
Minibatch error: 0.0%
Validation error: 1.8%
Step 1100 (epoch 1.28), 430.7 ms
Minibatch loss: 2.812, learning rate: 0.009500
Minibatch error: 0.0%
Validation error: 1.6%
Step 1200 (epoch 1.40), 426.2 ms
Minibatch loss: 2.891, learning rate: 0.009500
Minibatch error: 7.8%
Validation error: 1.5%
Step 1300 (epoch 1.51), 415.1 ms
Minibatch loss: 2.763, learning rate: 0.009500
Minibatch error: 0.0%
Validation error: 1.7%
Step 1400 (epoch 1.63), 418.8 ms
Minibatch loss: 2.774, learning rate: 0.009500
Minibatch error: 3.1%
Validation error: 1.5%
Step 1500 (epoch 1.75), 421.5 ms
Minibatch loss: 2.889, learning rate: 0.009500
Minibatch error: 7.8%
Validation error: 1.3