Implement AlexNet local response normalization across neighboring channels:
yb,h,w,c=(k+nα∑j=max(0,c−r)min(C−1,c+r)xb,h,w,j2)βxb,h,w,c,r=⌊2n⌋.Here, B,H,W,C are the batch, height, width, and channel dimensions. The positive odd integer n gives the full channel-window width away from boundaries. Return a float64 NumPy array with the same shape as x.
Examples
Input: x = [[[[1,2,3,0.5,-1]]]], k = 2, n = 5, alpha = 0.0001, beta = 0.75
Output: [[[[0.594541,1.18908,1.783607,0.29727,-0.594558]]]]
Explanation: Each channel uses the squared values inside its clipped five-channel neighborhood.
Input: x = [[[[1,-2,3]]]], k = 1, n = 1, alpha = 0.1, beta = 0.5
Output: [[[[0.953463,-1.690309,2.176429]]]]
Input: x = [[[[1,2,3]],[[3,2,1]]]], k = 2, n = 3, alpha = 0.01, beta = 0.75
Output: [[[[0.590914,1.168812,1.755363]],[[1.755363,1.168812,0.590914]]]]
Hint 1
Loop over the channel index and clip the local slice with max and min.
Hint 2
Sum x[..., start:stop] ** 2 along the last axis.
Requirements
- Normalize each value using squared activations from its local channel window.
- Clip the channel window at the first and last channels.
- Preserve the input shape and return float64 values.
Constraints
- x has shape (B,H,W,C) and contains finite values.
- n is a positive odd integer.
- k>0, α≥0, and β>0.
All steps in AlexNet
- Convolutional Layers
- ReLU Activation
- Dropout Regularization
- Local Response Normalization
- Overlapping Max Pooling
- Data Augmentation
Accepts: array
Accepts: number
Accepts: number
Accepts: number
Accepts: number
Local Response Normalization
Implement AlexNet local response normalization across neighboring channels:
yb,h,w,c=(k+nα∑j=max(0,c−r)min(C−1,c+r)xb,h,w,j2)βxb,h,w,c,r=⌊2n⌋.Here, B,H,W,C are the batch, height, width, and channel dimensions. The positive odd integer n gives the full channel-window width away from boundaries. Return a float64 NumPy array with the same shape as x.
Examples
Input: x = [[[[1,2,3,0.5,-1]]]], k = 2, n = 5, alpha = 0.0001, beta = 0.75
Output: [[[[0.594541,1.18908,1.783607,0.29727,-0.594558]]]]
Explanation: Each channel uses the squared values inside its clipped five-channel neighborhood.
Input: x = [[[[1,-2,3]]]], k = 1, n = 1, alpha = 0.1, beta = 0.5
Output: [[[[0.953463,-1.690309,2.176429]]]]
Input: x = [[[[1,2,3]],[[3,2,1]]]], k = 2, n = 3, alpha = 0.01, beta = 0.75
Output: [[[[0.590914,1.168812,1.755363]],[[1.755363,1.168812,0.590914]]]]
Hint 1
Loop over the channel index and clip the local slice with max and min.
Hint 2
Sum x[..., start:stop] ** 2 along the last axis.
Requirements
- Normalize each value using squared activations from its local channel window.
- Clip the channel window at the first and last channels.
- Preserve the input shape and return float64 values.
Constraints
- x has shape (B,H,W,C) and contains finite values.
- n is a positive odd integer.
- k>0, α≥0, and β>0.
All steps in AlexNet
- Convolutional Layers
- ReLU Activation
- Dropout Regularization
- Local Response Normalization
- Overlapping Max Pooling
- Data Augmentation
Accepts: array
Accepts: number
Accepts: number
Accepts: number
Accepts: number