First Layer Diagram
Detailed Diagram: Calculation for a Single Row in the Forward Pass¶
This diagram "zooms in" on the calculation process to generate the first row of dense1.output
.
Text Only
======================================================================================================
DETAILED FORWARD PASS DIAGRAM - CALCULATION FOR A SINGLE INPUT SAMPLE (FIRST ROW)
======================================================================================================
(INPUT - FIRST ROW OF X) (ENTIRE WEIGHT MATRIX W)
┌───────────┐ ┌───────────────────────┐
│ [x1, y1] │ │ [[w11, w12, w13], │
└─────┬─────┘ │ [w21, w22, w23]] │
│ └───────────┬───────────┘
└────────────────────────────────────────────────────────┘
│
▼
(1) DOT PRODUCT
"Multiply the row by each column"
┌───────────────────────────┴───────────────────────────┐
│ │
▼ (To calculate the FIRST value of the output row) ▼ (To calculate the SECOND value of the output row)
┌──────────────────────────┐ ┌──────────────────────────┐
│ [x1, y1] ● [w11, w21] │ │ [x1, y1] ● [w12, w22] │
│ (Row 1 of X ● Col 1 of W)│ │ (Row 1 of X ● Col 2 of W)│
│ │ │ │
│ x1 * w11 │ │ x1 * w12 │
│ + │ │ + │
│ y1 * w21 │ │ y1 * w22 │
│ = │ │ = │
│ o11 │ │ o12 │
└──────────┬───────────────┘ └────────────┬─────────────┘
│ │
└───────────────────────────┐ │
│ │
▼ ▼
┌─────────────────────────────────────────────────┐
│ dot_product (FIRST ROW) │
│ [o11, o12, o13] │ <-- o13 is calculated similarly with col 3 of W
└──────────────────────┬──────────────────────────┘
│
▼
(2) ADD BIAS
│
┌────────────────┴────────────────┐
│ │
▼ ▼
┌───────────────────┐ ┌───────────────────┐
│ [o11, o12, o13] │ │ [b1, b2, b3] │
└─────────┬─────────┘ └─────────┬─────────┘
│ │
└───────────────► + ◄─────────────┘
│
▼
┌───────────────────────────┐
│ output (FIRST ROW) │
│ [o11+b1, o12+b2, o13+b3] │
└───────────────────────────┘
------------------------------------------------------------------------------------------------------
* IMPORTANT: This process is repeated for ALL 100 rows of the input matrix X to create the 100 rows
* of the output matrix `dense1.output`. NumPy performs all these calculations in parallel very
* efficiently.
------------------------------------------------------------------------------------------------------