tensorflow常用函数总结

标量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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值