Implement the numerical U-Net bottleneck in NHWC layout. Apply two supplied same-padded convolutions, adding the corresponding bias and applying ReLU after each convolution.
Y=ReLU(ConvK2(ReLU(ConvK1(X))))Here, X is the lowest-resolution encoder tensor and K1 and K2 are odd-sized convolution kernels. Same zero padding preserves height and width. Return Y as a float64 NumPy array.
Examples
Input: x = [[[[1,-2]]]], kernel1 = [[[[1],[0.5]]]], bias1 = [0.2], kernel2 = [[[[2,-1]]]], bias2 = [0,0.5]
Output: [[[[0.4,0.3]]]]
Explanation: The bottleneck applies two learned convolution stages without pooling or upsampling.
Input: x = [[[[1],[-1]],[[0.5],[2]]]], kernel1 = [[[[2]]]], bias1 = [-0.5], kernel2 = [[[[0.25]]]], bias2 = [0.1]
Output: [[[[0.475],[0.1]],[[0.225],[0.975]]]]
Input: x = [[[[0,0]]]], kernel1 = [[[[1,-1],[0.5,2]]]], bias1 = [0.3,-0.2], kernel2 = [[[[1],[-1]]]], bias2 = [0.1]
Output: [[[[0.4]]]]
Hint 1
Pad the two spatial axes by kernel_size // 2.
Hint 2
Apply ReLU after adding each convolution bias.
Requirements
- Use NumPy.
- Apply both supplied convolutions in order.
- Add each supplied bias before its ReLU.
- Use same zero padding.
- Return a float64 NumPy array.
Constraints
- x has NHWC layout and dtype float64.
- Both kernels are square with a positive odd spatial size.
- Kernel channels and bias lengths match adjacent tensors.
- All kernels and biases have dtype float64.
All steps in U-Net
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
U-Net Bottleneck
Implement the numerical U-Net bottleneck in NHWC layout. Apply two supplied same-padded convolutions, adding the corresponding bias and applying ReLU after each convolution.
Y=ReLU(ConvK2(ReLU(ConvK1(X))))Here, X is the lowest-resolution encoder tensor and K1 and K2 are odd-sized convolution kernels. Same zero padding preserves height and width. Return Y as a float64 NumPy array.
Examples
Input: x = [[[[1,-2]]]], kernel1 = [[[[1],[0.5]]]], bias1 = [0.2], kernel2 = [[[[2,-1]]]], bias2 = [0,0.5]
Output: [[[[0.4,0.3]]]]
Explanation: The bottleneck applies two learned convolution stages without pooling or upsampling.
Input: x = [[[[1],[-1]],[[0.5],[2]]]], kernel1 = [[[[2]]]], bias1 = [-0.5], kernel2 = [[[[0.25]]]], bias2 = [0.1]
Output: [[[[0.475],[0.1]],[[0.225],[0.975]]]]
Input: x = [[[[0,0]]]], kernel1 = [[[[1,-1],[0.5,2]]]], bias1 = [0.3,-0.2], kernel2 = [[[[1],[-1]]]], bias2 = [0.1]
Output: [[[[0.4]]]]
Hint 1
Pad the two spatial axes by kernel_size // 2.
Hint 2
Apply ReLU after adding each convolution bias.
Requirements
- Use NumPy.
- Apply both supplied convolutions in order.
- Add each supplied bias before its ReLU.
- Use same zero padding.
- Return a float64 NumPy array.
Constraints
- x has NHWC layout and dtype float64.
- Both kernels are square with a positive odd spatial size.
- Kernel channels and bias lengths match adjacent tensors.
- All kernels and biases have dtype float64.
All steps in U-Net
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array