Transposed-Conv Output Size
~8 mincode completion
Implement conv_transpose_out_size(h_in, stride, pad, kernel) returning the integer Hout.
Examples
4, stride 2, pad 1, kernel 4 grows to 8
- Input
- conv_transpose_out_size(4, 2, 1, 4)
- Output
- 8
A 1x1 latent with stride 1, pad 0, kernel 1 stays 1
- Input
- conv_transpose_out_size(1, 1, 0, 1)
- Output
- 1
8, stride 2, pad 0, kernel 3
- Input
- conv_transpose_out_size(8, 2, 0, 3)
- Output
- 17
Hints
Hint 1
Work directly with the arguments h_in, stride, pad, and return the result rather than printing it.
Hint 2
Watch for this: used the forward conv formula.
Requirements
Return integer
Constraints
Standard library only, no imports required
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
def conv_transpose_out_size(h_in, stride, pad, kernel):
"""
Spatial size after a transposed conv with output_padding=0.
Args:
h_in, stride, pad, kernel: integers
Returns:
integer
"""
# YOUR CODE HERE
pass