TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理。Tensor(张量)意味着N维数组,Flow(流)意味着基于数据流图的计算,TensorFlow为张量从流图的一端流动到另一端计算过程。TensorFlow是将复杂的数据结构传输至人工智能神经网中进行分析和处理过程的系统。
TensorFlow可被用于语音识别或图像识别等多项机器深度学习领域,对2011年开发的深度学习基础架构DistBelief进行了各方面的改进,它可在小到一部智能手机、大到数千台数据中心服务器的各种设备上运行。TensorFlow将完全开源,任何人都可以用。
原生接口文章
- 【Tensorflow】tf.placeholder函数
- 【TensorFlow】tf.nn.conv2d是怎样实现卷积的
- 【TensorFlow】tf.nn.max_pool实现池化操作
- 【Tensorflow】tf.nn.relu函数
- 【Tensorflow】tf.reshape 函数
- 【Tensorflow】tf.nn.dropout函数
- 【Tensorflow】tf.argmax函数
- 【Tensorflow】tf.cast 类型转换 函数
- 【Tensorflow】tf.train.AdamOptimizer函数
- 【Tensorflow】tf.Graph()函数
- 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits的用法
- 【Tensorflow】tf.dynamic_partition 函数 分拆数组
slim接口文章
- 【Tensorflow】tensorflow.contrib.slim 包
- 【Tensorflow slim】 slim.arg_scope的用法
- 【Tensorflow slim】slim.data包
- 【Tensorflow slim】slim evaluation 函数
- 【Tensorflow slim】slim layers包
- 【Tensorflow slim】slim learning包
- 【Tensorflow slim】slim losses包
- 【Tensorflow slim】slim nets包
- 【Tensorflow slim】slim variables包
- 【Tensorflow slim】slim metrics包
kera 接口文章
tensorflow使用过程中的辅助接口或通过tensorflow实现的批量操作接口
tf.reshape(tensor, shape, name=None) 数据重定形状函数
参数:
- tensor:输入数据
- shape:目标形状
- name:名称
例:
# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]
# tensor 't' 的形状就是 [9]
reshape(t, [3, 3]) ==> [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
# tensor 't' is [[[1, 1], [2, 2]],
# [[3, 3], [4, 4]]]
# tensor 't' 当前形状是 [2, 2, 2]
reshape(t, [2, 4]) ==> [[1, 1, 2, 2],
[3, 3, 4, 4]]
# tensor 't' is [[[1, 1, 1],
# [2, 2, 2]],
# [[3, 3, 3],
# [4, 4, 4]],
# [[5, 5, 5],
# [6, 6, 6]]]
# tensor 't' 形状是 [3, 2, 3]
# pass '[-1]' 扁平化 't'
reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]
# -1 也可以被用于shape中
# -1 被推断结果是 9:
reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]]
# -1 被推断结果是 2:
reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]]
# -1 被推断结果是 3:
reshape(t, [ 2, -1, 3]) ==> [[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]
# tensor 't' is [7]
# shape `[]` 重塑为标量,用[]的时候,t只是有一个元素,不然会报错
reshape(t, []) ==> 7
测试代码
import tensorflow as tf
t = [7]
k = tf.reshape(t,[])
sess = tf.Session()
kk = sess.run(k)
print(kk)