标量scalar单个实数 |
维度0 shape:[] |
向量vector n个实数有序集合 |
维度1 shape:[n] |
矩阵matrix n行m列实数有序集合 |
维度2 shape[n,m] |
张量tensor 维度大于2数组 |
维度>2每个维度称为轴axis shape[b,w,h,c] |
标量向量矩阵张量 统称张量 |
|
标量创建 |
a=tf.constant(1.2) shape:() |
Type(变量) |
查看变量类型 |
张量创建 |
tf.constant([1,2,3]) shape(3,) 通过list数据类型传递给tf.constant()函数 |
x.numpy() |
张量方法返回np.array数据类型 |
a=tf.constant([[1,2],[3,4]]) |
Shape(2,2) dtype=int32/float32…… |
字符串tf.constant(‘zifuchuan’) |
Shape:() dtype=string 小写lower() 拼接join() 长度length() 切分split() 调用方法tf.string.lower(字符串变量) |
布尔类型tf.constant(True) |
Shape:() dtype=bool |
布尔数组(掩码)tf.constant([True,False]) |
Shape:(2,)dtype=bool |
数值精度类型 |
tf.int16 tf.int32 tf.int64 tf.float16 tf.float32 tf.float64=tf.double |
创建张量,指定数据精度 |
tf.constant(123,dtype=tf.int16) |
tensorflow常用函数总结
最新推荐文章于 2022-05-12 21:14:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)