TensorFlow

目录

安装 TensorFlow

  • 安装虚拟环境
$ pip3 install --upgrade virtualenv
  • 创建 Virtualenv 环境
$ virtualenv --system-site-packages -p python3 ~/Desktop/tensorflow
  • 激活该 Virtualenv 环境
$ cd ~/Desktop/tensorflow
$ source ./bin/activate  # If using bash, sh, ksh, or zsh

激活之后就变成了:

(tensorflow)$
  • 退出 Virtualenv 环境
(tensorflow)$ deactivate
  • 安装 TensorFlow 及其需要的所有软件包至 Virtualenv 环境中
(tensorflow)$ pip3 install --upgrade tensorflow
  • 卸载 TensorFlow, 只需移除之前创建的目录即可
$ rm -r ~/Desktop/tensorflow
  • 尝试运行 TensorFlow
(tensorflow)$ python
>>> import tensorflow as tf
>>> session = tf.Session()
>>> hello = tf.constant('hello, master jiangtao')
>>> session.run(hello)
b'hello, master jiangtao'
>>> print(type(session.run(hello)))
<class 'bytes'>
>>> a = tf.constant(3)
>>> b = tf.constant(2)
>>> print(session.run(a + b))
5

安装 Pandas

  • pip安装
(tensorflow)$ pip3 install pandas

获取示例程序

  • 克隆 TensorFlow 模型代码库
$ git clone https://github.com/tensorflow/models
  • 运行示例程序
$ cd models/samples/core/get_started/
$ python premade_estimator.py
Last Updated: 2019/12/6 18:34:45