简体   繁体   English

稀疏矩阵的点积

[英]Dot product of sparse matrix

Im reading implementation of the Multinomial Naive Bayes and I do not understand how does this following calculation of dot product of the following matrixes work. 我正在阅读朴素贝叶斯多项式的实现,并且我不理解以下矩阵的点积计算后的工作原理。

self.feature_count_ += safe_sparse_dot(Y.T, X)

Code can be found here 代码可以在这里找到

Where YTshape = (3, 7000) and X.shape = (7000, 27860). 其中YTshape =(3,7000)和X.shape =(7000,27860)。 How can it work when number of rows in the YT is not equal to number of columns in X ? YT的行数不等于X的列数时,如何工作? The size of the resulting matrix is (3, 27860) ?? 所得矩阵的大小为(3,27860)?? How does it work? 它是如何工作的? What am I missing? 我想念什么?

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

Check out the "Mulitplying a matrix by another matrix" section here: https://www.mathsisfun.com/algebra/matrix-multiplying.html 在此处查看“通过另一个矩阵多重化一个矩阵”部分: https ://www.mathsisfun.com/algebra/matrix-multiplying.html

If you go through the multiplication, you'll see that only the "inner" dimensions have to match (the 7000 in your case) 如果进行乘法运算,您将看到只有“内部”尺寸必须匹配(在您的情况下为7000)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM