下载
- Python3.5.x,https://www.python.org/downloads/release/python-352/
- 设置python全局变量
- 验证python版本,
python --version
- 下载tensorflow,pip3 install --upgrade tensorflow,公司网络,安装未发现问题。
- GPU版本暂时略。
- 验证TF安装成功。
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
- 运行查看输出
b'Hello, TensorFlow!'
简介
TensorFlow provides multiple APIs. The lowest level API--TensorFlow Core-- provides you with complete programming control. We recommend TensorFlow Core for machine learning researchers and others who require fine levels of control over their models. The higher level APIs are built on top of TensorFlow Core. These higher level APIs are typically easier to learn and use than TensorFlow Core. In addition, the higher level APIs make repetitive tasks easier and more consistent between different users. A high-level API like tf.contrib.learn helps you manage data sets, estimators, training and inference. Note that a few of the high-level TensorFlow APIs--those whose method names contain contrib-- are still in development. It is possible that some contrib methods will change or become obsolete in subsequent TensorFlow releases.
这段话是什么意思
- TensorFlow提供了很多API。
- 最底层的API是TensorFlow Core,这个库给你提供了全部的编程控制接口。
- 高级接口是在TensorFlow Core基础上构建的。
- 简单来说,这些高级接口非常的容易学习、掌握和运用。
什么是张量(Tensors)
- 张量是TensorFlow数据的中央单元。
- 一个张量包含一系列的原始数据。
- 这些原始数据组装进一个任意维度数组里。
- 阶层(Rank),是一个张量的维度。
例子
3 # 0阶层,形状[ ]
[1., 2., 3.] # 1阶层张量,形状[3]
[[1., 2., 3.], [4., 5., 6.]] # 2阶层张量,是一个两行三列的矩阵[2, 3]
[[[1., 2., 3.]], [[4., 5., 6.]] # 3阶张量,形如[2, 1, 3]