NumPy allowed · plain Python earns 10 bonus points
Calculate exact output spatial feature map dimensions for convolutional layers across various padding, stride, and dilation configurations.
Implement conv2d_output_shape(...): calculate the output spatial shape [out_H, out_W]. The effective kernel dimension with dilation d is k_eff = k + (k - 1) * (d - 1). The output dimension is floor((dim + 2 * pad - k_eff) / stride) + 1. Return [out_H, out_W] as integers.
conv2d_output_shape(H: int, W: int, kH: int, kW: int, pad_h: int = 0, pad_w: int = 0, stride_h: int = 1, stride_w: int = 1, dilation_h: int = 1, dilation_w: int = 1) -> list[int]