Matrix & Matrix Operations

Jantung dari Neural Networks

1. Matrix Transpose ($A^T$)

Memutar matriks terhadap diagonal utamanya. Baris jadi kolom, kolom jadi baris.

A (2x3)

$$ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} $$

$A^T$ (3x2)

$$ \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix} $$

2. Perkalian Matriks (Dot Product)

Syarat Utama: Jumlah Kolom Matriks A harus sama dengan Jumlah Baris Matriks B.
$(m \times \mathbf{n}) \cdot (\mathbf{n} \times p) = (m \times p)$

Cara hitung: "Baris kali Kolom".

$$ \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \times \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} (1\cdot5 + 2\cdot7) & (1\cdot6 + 2\cdot8) \\ (3\cdot5 + 4\cdot7) & (3\cdot6 + 4\cdot8) \end{bmatrix} $$ $$ = \begin{bmatrix} (5+14) & (6+16) \\ (15+28) & (18+32) \end{bmatrix} = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} $$

3. Hadamard Product (Element-wise)

Beda dengan matrix multiplication! Ini hanya mengalikan elemen di posisi yang sama.

Notasi: $\mathbf{A} \odot \mathbf{B}$

$$ \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \odot \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} 1\cdot5 & 2\cdot6 \\ 3\cdot7 & 4\cdot8 \end{bmatrix} = \begin{bmatrix} 5 & 12 \\ 21 & 32 \end{bmatrix} $$

*Ukuran matriks harus sama persis.

4. Identity Matrix ($I$)

Matriks Identitas adalah "Angka 1"-nya dunia matriks.

  • Matriks Persegi (Baris = Kolom).
  • Diagonal utama isinya 1, sisanya 0.
  • Sifat: $\mathbf{A} \cdot \mathbf{I} = \mathbf{A}$ dan $\mathbf{I} \cdot \mathbf{A} = \mathbf{A}$.
$$ I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} $$