Shape mismatches are the most common deep learning bug. Implement PyTorch's formulas:
conv_out(n, k, stride=1, padding=0, dilation=1): conv_transpose_out(n, k, stride=1, padding=0, dilation=1, output_padding=0): same_padding(k, dilation=1): the padding that keeps the size unchanged at stride 1, for odd effective kernel sizes: conv_params(c_in, c_out, k, groups=1, bias=True): weights , plus biasesseparable_params(c_in, c_out, k): a depthwise k×k convolution (groups = c_in, with bias) followed by a pointwise 1×1 convolution (with bias)trace_shapes(n, layers): apply a list of (k, stride, padding) conv layers to a size n and return the list of sizes after each layer