Gradient Ascent
Motivation
We want to generate a synthetic image that maximally activates a neuron. That is, make a neuron output maximum value.
Mathematical Expression
We can conclude what we are doing in a math equation:
Explanation:
- : The image we are generating
- : Current neuron value
- : Natural image regularizer
- Initialize image pixel values to zeros
Repeat:
- Forward pass to computer current neuron value
- Backprop to get gradient of the neuron value with respect to image pixels
- Update the image based on the gradients
If we choose neuron in last layer, then the neuron value is the classification score
Recommendation
Regularizer
Use L2 regularizer to penalize the synthetic image pixel values
To make the synthetic image look more natural, we penalize the pixel values to avoid them having large RGB values
Optimization
To make the synthetic image more natural, we can:
- Gaussian blur the image
- Clip pixels with small values to 0
- Clip small gradients with respect to pixel value to 0
You can even add more complicated regularizer and optimization to make the synthetic image even more natural. However, this betrays our original goal of understanding the neuron, since we are putting too much effort in regularizing