linux中安装tensorflow

liunx
sudo apt-get install python-pip python-dev

python2.X -> pip
python3.X -> pip3

pip --version
pip install --upgrade pip
pip --version
pip3 --version

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

pip uninstall tensorflow

或者pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

第一个实例:

1。按上面,先安装好tensorflow

2.安装Inception-V3模型到任意目录中,并解压出来:

mkdir /mnt/tensorflow/model
cd /mnt/tensorflow/model
wget http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz
tar -zxvf inception-2015-12-05.tgz

3.把要识别的jpg放到一个目录下面:

例如:/mnt/tensorflow/test-images/1.jpg

4.执行

cd /usr/lib/python2.7/site-packages/tensorflow/models/image/imagenet

python classify_image.py --model_dir /mnt/tensorflow/model --image_file /mnt/tensorflow/test-images/1.jpg 

5.看输出结果,得出评分比较大的那个选项:

[root@izuf63bjp8ts8nkl13pxh1z imagenet]# python classify_image.py --model_dir /mnt/tensorflow/model --image_file /mnt/tensorflow/test-images/1.jpg
W tensorflow/core/framework/op_def_util.cc:332] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().
mountain bike, all-terrain bike, off-roader (score = 0.56188)
tricycle, trike, velocipede (score = 0.12604)
bicycle-built-for-two, tandem bicycle, tandem (score = 0.08763)
lawn mower, mower (score = 0.00637)
alp (score = 0.00387)

我图像识别的是一辆自行车。

第二个实例:

TensorBoard是Tensorflow的可视化工具。Tensorflow安装好后,TensorBoard自然就装好了。于是,下面只剩下怎么启动它的问题。

tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries

其中,--logdir参数指定的目录,TensorBoard会从这个路径下读取数据并可视化展示在web页面中。
过一会就会看到命令行提示:

Starting TensorBoard 41 on port 6006
(You can navigate to http://10.0.0.2:6006)
所以现在打开浏览器,访问这个地址,就可以看到图了。
原文地址:https://www.cnblogs.com/afangxin/p/6933649.html