当移动一个数组或向量时,我们需要一个索引;二维数组/矩阵需要两个索引,
比如说标量是零维张量,数组/向量/矢量是一维张量,矩阵是是二维张量,n维数组是n维张量。
如果我们被告知,
假设有一个张量t,第一二个轴长分别是3和4,因为第一个轴是3,我们就可以在第一个轴上标上3个位置,下图中t[0]~t[2]都是有效的,
对于tensor来说,最后一个轴的元素总是数字,每个轴都包含一个N维数组;这个概念可以概括为任何N维张量,所以一个张量的秩告诉我们,此张量有多少个轴。
这是因为在pytorch中,一个张量的大小(size)和一个张量的形状(shape)是一样的。对于不同的概念我们有多歌词来描述。
就像同样一个概念在不同的领域被独立的创造出来,最终他们都找到了机器学习的方法。异名同义。
,这个形状也揭露了张量的秩。
一个变量的秩等于他的形状的长度。e.g.: plt.scatter(x,y); -> x.shape#结果可能是(50,);->但是len(x.shape)结果就是1;