目录
一、张量创建
二、张量的操作
1、tf.strings
2、tf.debugging
3、tf.random
4、tf.math
5、tf.dtypes
一、张量创建
import tensorflow as tf
print (tf.__version__) ###打印tensorflow版本号
print (tf.test.is_gpu_available()) ###打印是否有gpu
#Rank 0
mamal = tf.Variable("Elephant",tf.string)
tf.print(tf.rank(mamal))
#Rank 1 一阶张量
mystr = tf.Variable(["Hello"],tf.string)
tf.print(tf.rank(mystr))
tf.print(tf.shape(mystr))
#Rank 2 二阶张量
mymat = tf.Variable([[7],[11]],tf.int16)
tf.print(tf.rank(mymat))
tf.print(tf.shape(mymat))
二、张量的操作
1、tf.strings
tf.strings.bytes_split('hello') ###按照字符切割,把0阶转换为1阶
tf.strings.split('hello world') ###单次切割 默认把句子按照空格切割,0阶变成1阶
tf.strings.to_hash_bucket(['hello','world'], num_buckets=10) ###string hash
tf.strings.bytes_split('hello') ###按照字符切割,把0阶转换为1阶
tf.strings.split('hello world') ###单次切割 默认把句子按照空格切割,0阶变成1阶
tf.strings.to_hash_bucket(['hello','world'], num_buckets=10) ###string hash



