TensorFlow张量
本文记录的是TensorFlow中的张量基础知识,包含:
张量类型
张量数据类型
张量创建
张量类型
维数 阶 名字 例子
0-D 0 标量scalar s = 1,2,3
1...判断张量是几阶,就看有几个[]
TensorFlow数据类型
tf.int, tf.float:tf.int32、tf.float32、tf.float64
tf.bool:tf.constant([True...创建张量Tensor
创建张量的一般方式:
tf.constant(张量内容, dtype=数据类型[可选])
直接生成
import tensorflow as tf
import numpy as...[0, 1, 0],
[0, 0, 1],
[0, 0, 0]])>
c.dtype
tf.int64
print(c.shape)
(4, 3)
方式2:将numpy...shape=(5,), dtype=int64, numpy=array([0, 1, 2, 3, 4])>
arr_to_tf.shape
TensorShape([5])
type(arr_to_tf)
tensorflow.python.framework.ops.EagerTensor