Daily Dose of Data Science

Share this post

Difference Between Dot and Matmul in NumPy

www.blog.dailydoseofds.com

Difference Between Dot and Matmul in NumPy

Avi Chawla
Dec 22, 2022
Share
Share this post

Difference Between Dot and Matmul in NumPy

www.blog.dailydoseofds.com

The ๐ง๐ฉ.๐ฆ๐š๐ญ๐ฆ๐ฎ๐ฅ() and ๐ง๐ฉ.๐๐จ๐ญ() methods produce the same output for 2D (and 1D) arrays. This makes many believe that they are the same and can be used interchangeably, but that is not true.

The ๐ง๐ฉ.๐๐จ๐ญ() method revolves around individual vectors (or 1D arrays). Thus, it computes the dot product of ALL vector pairs in the two inputs.

The ๐ง๐ฉ.๐ฆ๐š๐ญ๐ฆ๐ฎ๐ฅ() method, as the name suggests, is meant for matrices. Thus, it computes the matrix multiplication of corresponding matrices in the two inputs.

Thanks for reading Daily Dose of Data Science! Subscribe for free to receive new posts and support my work.


Find the code for my tips here:ย GitHub.

I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.

Share
Share this post

Difference Between Dot and Matmul in NumPy

www.blog.dailydoseofds.com
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

ยฉ 2023 Avi Chawla
Privacy โˆ™ Terms โˆ™ Collection notice
Start WritingGet the app
Substackย is the home for great writing