运行和验证

TensorFlow 1.15.5编译安装完成后使用自带样例进行基本功能的验证。本文使用自带样例中的图像识别样例来验证TensorFlow的基本功能。

  1. 版本验证,在TensorFlow非源码目录下执行。

    1
    python3 -c "import tensorflow as tf; print(tf.__version__)"
    

    回显信息显示,版本号为1.15.5。

  2. 基本功能验证。

    以TensorFlow自带样例图像识别为例。

    1. 进入TensorFlow源码编译规划路径。
      1
      cd /path/to/tensorflow
      
    2. 获取模型数据和验证数据。
      1
      2
      curl -L "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz" | tar -C tensorflow/examples/label_image/data -xz
      wget -P tensorflow/examples/label_image/data/  https://www.tensorflow.org/images/cropped_panda.jpg --no-check-certificate
      
    3. 执行测试用例。
      1
      python3 tensorflow/examples/label_image/label_image.py --image=tensorflow/examples/label_image/data/cropped_panda.jpg
      

      回显信息显示,将图片“tensorflow/examples/label_image/data/cropped_panda.jpg”识别为giant panda类别的概率最大。