1. Introduction to Neural Networks¶
Neural Networks are non-linear statistical models used for both regression and classification. They are inspired by biological neurons and consist of interconnected processing units (neurons) organized into layers.
Input Layer: Receives the raw feature vector .
Hidden Layer(s): Intermediate layers that extract increasingly abstract features.
Output Layer: Produces the final prediction .
2. The Artificial Neuron (Perceptron)¶
A single neuron computes a weighted sum of its inputs, adds a bias, and applies a non-linear activation function.
Mathematical Formulation¶
For a neuron with input vector :
Linear Combination:
Non-linear Activation:
where is the weight vector, is the bias, and is the activation function.
Common Activation Functions¶
Activation functions introduce non-linearity, allowing the network to approximate complex functions.
Sigmoid: (Maps to )
Hyperbolic Tangent (Tanh): (Maps to )
Rectified Linear Unit (ReLU): (Standard for deep networks)
3. Multilayer Perceptrons (MLP)¶
In a feedforward network, neurons are arranged in layers where the output of one layer becomes the input of the next.
Forward Propagation¶
For a network with layers, let be the activation of layer :
where is the weight matrix for layer and .
4. Training and Loss Functions¶
To train the network, we define a cost function that measures the discrepancy between the prediction and the ground truth .
Mean Squared Error (Regression):
Cross-Entropy Loss (Classification):
5. Backpropagation and Optimization¶
Optimization is performed using Gradient Descent to minimize the loss function by updating weights and biases:
The Chain Rule¶
Backpropagation uses the chain rule to compute the gradient of the loss with respect to each parameter by moving backward through the network. For a weight in layer :
6. Feature Learning¶
A key advantage of Neural Networks over traditional methods (like Decision Trees) is their ability to learn hierarchical representations.
Early Layers: Typically learn low-level features (e.g., edges, blobs in images).
Deeper Layers: Combine low-level features into complex patterns (e.g., shapes, objects).
In tasks like handwritten digit classification ( pixels), hidden units act as feature detectors. Visualizing the weight vectors as images often reveals that the network has learned to respond strongly to specific strokes or orientations.
| Property | Neural Networks | Decision Trees |
|---|---|---|
| Feature Construction | Learned automatically via hidden layers. | Manual feature engineering or axis-aligned splits. |
| Boundaries | Smooth and non-linear. | Piecewise constant (box-like). |
| Scalability | High (with GPU/Big Data). | Becomes complex/unstable with very high dimensionality. |