Home / Maths for AI / Symbols / Vectors and matrices

Element-wise (Hadamard) product

Say it: "a circle-dot b", "element-wise times"

What it means

Multiply two arrays of the same shape entry by entry. Not the same as matrix multiplication. In NumPy it is *.

Example

(1,2,3)⊙(4,5,6)=(4,10,18)(1, 2, 3) \odot (4, 5, 6) = (4, 10, 18)

Each pair multiplied, no adding.

In code

import numpy as np
print(np.array([1, 2, 3]) * np.array([4, 5, 6]))

Output

[ 4 10 18]

Where it appears in machine learning

Gates in LSTMs, masks in attention, and dropout are element-wise products.

Related symbols

Learn it properly in the free lesson Matrices, with practice questions that check your answers.