def get_output_shape(kernel_size, stride, padding, H_prev, W_prev):
    """Get the output shape given kernal size, stride, padding, input size."""
    k_H, k_W = kernel_size
    stride_H, stride_W = stride
    pad_H, pad_W = padding

    H = int((H_prev - k_H + 2 * pad_H) / stride_H) + 1
    W = int((W_prev - k_W + 2 * pad_W) / stride_W) + 1

    return H, W