1. ReLU (Rectified Linear Unit) Activation Function
Definition:
The ReLU function is defined as:
f(x)=max(0,x)
or equivalently:
f(x)={0xif x≤0if x>0
Graph Representation:
The graph of the ReLU function looks like this:
/
/
/
/
---/--------
-inf inf
In simpler terms, for any input value:
- If x≤0, f(x)=0.
- If x>0, .
Example:
- f(5)=5 (because 5 is positive)
- f(−3)=0 (because -3 is negative)
Pros and Cons:
Pros:
- Computationally Efficient: ReLU is very simple and fast to compute.
- Sparse Activation: It produces sparse activations, which can help with regularization and reduce overfitting.
Cons:
- Dead Neurons: If a neuron's output is consistently negative, its output will be stuck at zero, making it "dead" (more on this later).
- Non-Differentiable at Zero: The derivative of ReLU is not defined at x=0, which can cause issues in some optimization algorithms.
2. Softmax Activation Function
Definition:
The Softmax function is used for multi-class classification problems. It takes a vector of real numbers and outputs a vector of values between 0 and 1, which add up to 1.
Given a vector z=[z1,z2,...,z, the Softmax function is defined as:
softmax(zi)=∑j
Graph Representation:
The graph of the Softmax function for a 2D input looks like a smooth, continuous curve that maps inputs to probabilities.
Example:
Suppose we have a vector z=[2.0,1.0,0.1].
- e2.0=7.389
- e1.0=2.718
∑ezi=7.389+2.718+1.105=11.212
softmax(z)=[7.389/11.212,2.718/11.212,1.105/11.212]≈[0.659,0.242,0.099]
Pros and Cons:
Pros:
- Interpretability: Outputs can be interpreted as probabilities.
- Differentiable: Softmax is differentiable, making it suitable for gradient-based optimization.
Cons:
- Computational Cost: It can be computationally expensive, especially for large output layers.
- Sensitive to Input Scale: The Softmax function is sensitive to the scale of the input values.
3. Dead Neurons in Neural Networks
What are Dead Neurons?
In a neural network, a "dead neuron" refers to a neuron that, due to the choice of activation function (commonly ReLU), outputs zero for all inputs. This happens when the learning process causes the neuron's weights to be updated in such a way that the neuron's output is consistently negative.
Why do Dead Neurons Occur?
Dead neurons typically occur with the ReLU activation function because:
- If the input to a ReLU neuron is negative, the output is zero.
- If the neuron's output is zero, the gradient of the loss with respect to the neuron's input is zero (since the derivative of ReLU is zero for negative inputs).
- As a result, the neuron's weights do not get updated during backpropagation, and the neuron remains "dead."
Impact of Dead Neurons:
- Reduced Capacity: Dead neurons do not contribute to the network's ability to learn or make predictions.
- Wasted Resources: The computational resources used to process dead neurons are wasted.
Mitigation Strategies:
- Leaky ReLU: A variation of ReLU that allows a small fraction of the input to pass through, even if it's negative.
- Parametric ReLU (PReLU): A learnable version of Leaky ReLU.
- Batch Normalization: Helps stabilize and normalize the inputs to layers, reducing the likelihood of neurons becoming stuck in a negative region.
By understanding these concepts, you can better design and optimize neural networks for various tasks.