U-Net Skip Concatenation
~8 mincode completion
Implement unet_skip_concat(encoder, decoder) returning the concatenated map.
Examples
A 2x2x3 map and a 2x2x1 map become 2x2x4
- Input
- unet_skip_concat([[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]], [[[2], [2]], [[2], [2]]])
- Output
- [[[1, 1, 1, 2], [1, 1, 1, 2]], [[1, 1, 1, 2], [1, 1, 1, 2]]]
Encoder channels come first
- Input
- unet_skip_concat([[[3, 4]]], [[[5, 6, 7]]])
- Output
- [[[3, 4, 5, 6, 7]]]
Hints
Hint 1
Join the pieces along the feature axis, not the row axis.
Hint 2
Watch for this: concatenated on the spatial axis.
Requirements
: (H, W, C_e)
decoder: (H, W, C_d)Return (H, W, C_e + C_d)
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~8 min
••••••••••••••••
8 employers weight this skill
4 autonomy companies, 1 enterprise vendor, 1 defense company, 1 health and bio company, 1 AI product company. Top match scores 87.
Python
import numpy as np
def unet_skip_concat(encoder, decoder):
"""
Concatenate encoder and decoder maps on the channel axis.
Args:
encoder: (H, W, C_e)
decoder: (H, W, C_d)
Returns:
(H, W, C_e + C_d)
"""
# YOUR CODE HERE
pass