SoFunction
Updated on 2024-12-13

Example of PyTorch Corresponding Point Multiplication, Matrix Multiplication

One, corresponding to the multiplication of points, (y) , i.e., point multiplication operation, point multiplication without summation operation, which can also be called Hadamard product; point multiplication and then summation, i.e., convolution

data = [[1,2], [3,4], [5, 6]]
tensor = (data)
 
tensor
Out[27]: 
tensor([[ 1., 2.],
    [ 3., 4.],
    [ 5., 6.]])
 
(tensor)
Out[28]: 
tensor([[ 1.,  4.],
    [ 9., 16.],
    [ 25., 36.]])

Second, matrix multiplication, (y) , matrix size needs to satisfy: (i, n)x(n, j)

tensor
Out[31]: 
tensor([[ 1., 2.],
    [ 3., 4.],
    [ 5., 6.]])
 
(()) # t() is transposed
Out[30]: 
tensor([[ 5., 11., 17.],
    [ 11., 25., 39.],
    [ 17., 39., 61.]])

The above piece (title) is all I have to share with you.