一、tf.constant()
数据类型:
- int
- float
- double
- bool
- string
(1)直接constant变量
(2)constant()指定dtype
type要匹配,不然会报错
二、tensor属性
-
device
-
转numpy()
-
ndim
-
rank
三、类型判断
- isinstance()
- is_tenosr()
- x.dtype
四、类型转换
1.convert_to_tensor()
numpy -> tensor
2.numpy()
tensor -> numpy
3.cast()
tensor -> 其他tf数据类型
tf数据类型 bool - int
4.tensor -> float() int()
先转numpy 再转int float