TensorFlow创建tensor语句
生活随笔
收集整理的這篇文章主要介紹了
TensorFlow创建tensor语句
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
學(xué)習(xí)課程
1.np.array轉(zhuǎn)tf:
2.tf.zeros
tf.zeros([]) #一個(gè)數(shù) tf.zeros([2]) #一個(gè)向量 tf.zeros([2,2]) #一個(gè)矩陣 tf.zeros([2,3,3])3.tf.zeros_like
a = tf.zeros([2,1]) tf.zeros_like(a) #和a大小一致的tensortf.zeros(a.shape)4.tf.ones
tf.ones(1) #一維向量 tf.ones([]) #一個(gè)數(shù) tf.ones([2]) #二維向量 tf.ones([2,2]) tf.ones_like(a)5.Fill
tf.fill([2.3],2) #2*3矩陣。每個(gè)數(shù)都是26.Normal
tf.random.normal([2,3],mean=1,stddev=1) #2*3矩陣,每個(gè)數(shù)服從均值為1 方差為1的正態(tài)分布 tf.random.trunated_normal([2,3],mean=1,stddev=1)7.uniform
tf.random.uniform([2,3],minval=0,maxval=100,tf.dtype = tf.int32) #均勻分布8.Random Permutation
idx = tf.range(10) idx = tf.random.shuffle(idx) #隨機(jī)打散9.tf.constant
tf.tf.constant(1) #數(shù)值為1 tf.tf.constant([1]) #向量為[1] tf.tf.constant([1,2]) #向量為[1,2]總結(jié)
以上是生活随笔為你收集整理的TensorFlow创建tensor语句的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux命令集合(更新中。。。)
- 下一篇: TensorFlow索引与切片语句