张量点:使用 python 进行深度学习

Tensor dot: deep learning with python

我目前正在阅读 Deep Learning with Python 我不确定作者在第 42 页上想说什么。link 是here

More generally, you can take the dot product between higher-dimensional tensors, following the same rules for shape compatibility as outlined earlier for the 2D case:

(a, b, c, d) . (d,) -> (a, b, c)
(a, b, c, d) . (d, e) -> (a, b, c, e)

不确定他想在这里说什么。我明白矩阵乘法是如何工作的,但是上面两行代码不清楚。

按照这种表示法,矩阵乘法是

(a, b) * (b, c) -> (a, c)

当第二个矩阵为向量时,化简为

(a, b) * (b, ) -> (a, )

现在,书中的公式简单地解释了当第一个或第二个矩阵具有额外维度时如何扩展此操作。重要的是两者都有匹配的维度(最后一个暗淡==第一个暗淡,没有整形),张量可以沿着它相乘,消除这个维度。因此,结果形状的公式:

(a, b, c, d) * (d, e) -> (a, b, c, e)