#132Feature map — bias and ReLUEasyCNNComputer VisionActivation Functions
Feature map — bias and ReLU
Background
After the convolution sum, a conv layer adds a bias and applies a nonlinearity (usually ReLU) to the whole feature map:
ReLU keeps the "pattern detected" (positive) signal and zeroes the rest, so depth doesn't collapse into a single linear map.
Problem statement
Implement feature_map_relu(feature_map, bias) that adds bias to every entry and applies ReLU.
Input
feature_map— array-like 2D of pre-activation convolution outputs.bias—float.
Output
Returns an np.ndarray the same shape: max(0, feature_map + bias).
Examples
Example 1 — the lesson's grid (bias 0)
Input: feature_map = [[-2, 3], [4, -1]], bias = 0
Output: [[0 3], [4 0]]
Explanation: negatives clip to 0.
Example 2 — a negative bias raises the threshold
Input: feature_map = [[1, 1]], bias = -2
Output: [[0 0]]
Explanation: .
Constraints
- Add the (scalar) bias to every entry, then
max(0, ·)elementwise. - Return an
np.ndarrayof the same shape.
Notes
- The bias shifts the ReLU threshold: a more negative bias makes the detector pickier (only strong responses survive).
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •example lesson grid bias 0
- •reference negative bias raises threshold
- •sample positive bias rescues