Review linear algebra and calculus essentials for ANNs
Nerd Cafe
1. Linear Algebra Essentials for ANNs
Vectors & Matrices
Vectors: 1D arrays (e.g., input features).
import numpy as np
x = np.array([1, 2, 3]) # Input vectorMatrices: 2D arrays (e.g., weights in a layer).
W = np.array([[1, 2], [3, 4]]) # Weight matrixPython Example:
import numpy as np
# Vectors
v1 = np.array([1, 2, 3])
v2 = np.array([4, 5, 6])
# Matrices
m1 = np.array([[1, 2], [3, 4]])
m2 = np.array([[5, 6], [7, 8]])
print("Vector v1:", v1)
print("Matrix m1:\n", m1)Output
Dot Product (Inner Product)
Computes weighted sums for neuron inputs:
Output:
Key Notes:
Dimensions:
x: Shape(3,)(3 input features).W: Shape(2, 3)(2 neurons, each with 3 weights).b: Shape(2,)(1 bias per neuron).Output
z: Shape(2,)(output of 2 neurons).
What This Represents:
Simulates a dense layer in ANNs.
Each neuron computes:
Matrix Multiplication
Critical for forward propagation in ANNs.
Output
Matrix Transpose
Concept: Flipping a matrix over its diagonal, swapping row and column indices.
Python Example:
Output
Special Matrices
Concept: Identity matrices (I), diagonal matrices, and their properties.
Python Example:
Output
2. Calculus Essentials
Derivatives and Gradients
Concept: The derivative measures how a function changes as its input changes. The gradient generalizes this to multiple dimensions.
Math:
Python Example:
Output

Partial Derivatives
Concept: How a multi-variable function changes when only one variable changes.
Math:
Python Example:
Output:
The Chain Rule
Concept: Essential for backpropagation in neural networks. Allows computation of derivatives of composite functions.
Math:
If
then
Example
Given:
Then:
We’ll use SymPy to define the functions and compute the derivative step by step.
Python Example:
Output
Last updated