How to perform efficient sparse matrix multiplication by using tf.matmul?

会有一股神秘感。 提交于 2019-11-29 12:30:16

The relative performance depends on many factor. Sparse multiplication can be faster than dense multiplication with dense matrix (hopefully), but you are right that it can also be slower.

For one thing, it depends on the size of your matrix.

Here is the result of the multiplication of two square matrices, one random and one filled with zeros, and recorded the computation time for dense and spare multiplication.

As you can see, even with a completely zero matrix, sparse multiplication can be slower than dense multiplication for smaller matrix size -- in fact almost three times slower for matrices about 120x120. In this experiment on my computer, sparse matrix multiplication starts taking over for sizes of about 700x700 and ends up being about 2 times faster. Of course YMMV depending on your configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!