我目前正在阅读使用 Python 进行深度学习,我不确定作者在第 42 页上想说什么。链接是 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, )
现在,书中的公式简单地解释了当第一个或第二个矩阵具有额外维度时如何扩展此操作。重要的是,两者都有一个匹配的维度(最后一个暗淡==第一个暗淡,无需 reshape ),张量可以沿着该维度相乘,从而消除这个维度。因此,结果形状的公式为:
(a, b, c, d) * (d, e) -> (a, b, c, e)
关于machine-learning - 张量点: deep learning with python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48082735/