Python and java achieve cosine similarity, and the difference between dot product and star product

Matrix multiplication, the difference between star multiplication (*) and dot multiplication (.dot)

1. Basic example

import numpy
a = numpy.array([[1,2],
                 [3,4]])
b = numpy.array([[5,6],
                 [7,8]])

a*b

array([[ 5, 12],
          [21, 32]])

a.dot(b)

array([[19, 22],
          [43, 50]])

numpy.dot(b,a)

array

Guess you like

Origin blog.csdn.net/HHTNAN/article/details/105546397