Element-wise multiplication

Hello All,

Could you please explain or give me some link about element-wise multiplication? What is the difference between it and other types of matrix multiplication?

Thank you very much in advance?

Hi @gadolinis,

Element-wise multiplication is done between two tensors that have exactly the same dimensions. The output is also a tensor with the same dimensions as the input. Each element in the output tensor is a multiplication of the two elements in the input tensors at the same position.

Matrix multiplication is defined differently. First, we are narrowing the discussion to matrices and vectors. A tensor can have as many dimensions as you choose. A matrix has two, and a vector has one.

You can read the definition of matrix multiplication here: Matrix multiplication - Wikipedia. One of the differences between this operation and an element-wise one is that the shapes of the multiplied matrices and the output one are not necessarily the same, and the relation between them follows certain rules, you can read about in the link I added.

Note that mathematically you can represent element-wise multiplication as a sequence of matrix-by-vector multiplications. However, computationally there are more efficient ways to perform element-wise operations

1 Like