Dot Product: Matrix Ɨ Vector

Basics

A layer of neurons is just multiple dot products stacked: each row of the weight matrix dots with the input vector to produce one neuron's output. Here we compute each neuron manually, then show how np.dot does the whole layer at once. • Matrix columns must equal vector length. • Not commutative: np.dot(W, x) ≠ np.dot(x, W).

Each row of W dots with input x to produce one output. Row 1: (0.2Ɨ1)+(0.8Ɨ2)+(āˆ’0.5Ɨ3)+0.1 = 0.4, Row 2: (0.5Ɨ1)+(āˆ’0.91Ɨ2)+(0.26Ɨ3)āˆ’0.2 = āˆ’0.74, Row 3: (āˆ’0.26Ɨ1)+(āˆ’0.27Ɨ2)+(0.17Ɨ3)+0.05 = āˆ’0.24.

Python
Shift+Enter to run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Step 0 / 0
Speed

Write Python code and press Shift+Enter or click "Run" to visualize.

Run the operation to see step-by-step explanation.