([2, 3])
print(b.shape)
(2, 3)
基于numpy数组
方式1:通过numpy数组来创建张量:
array = np.eye(4,3)
array
array([[1., 0....1]], dtype=int32)>
指定值的张量
tf.fill([2,3],8) # 指定shape和填充的数值
tf.Tensor: shape=(2, 3), dtype=int32, numpy...]], dtype=float32)>
生成均匀分布的张量
tf.random.uniform(维度,minval=最小值,maxval=最大值)
区间是前闭后开:[minval,maxval)
tf.random.uniform...tf.data.Dataset.from_tensor_slices:特征和标签配对
import tensorflow as tf
import numpy as np
理解axis
在一个二维张量或者数组中...[3]:
tf.Tensor: shape=(3,), dtype=int64, numpy=array([1, 2, 3])>
tf.reduce_max/min
计算张量维度上的最值
In [4]