- for stride in range(1, input_size + 1):
- if cond(kernel_size, stride):
- n = (input_size - kernel_size) // stride
- if n * stride + kernel_size == input_size:
- q = conv_chain(n + 1, output_size, depth - 1, cond)
- r += [ [ (kernel_size, stride) ] + u for u in q ]
+ for stride in range(1, input_size):
+ if cond(remain_depth, kernel_size, stride):
+ n = (input_size - kernel_size) // stride + 1
+ if (
+ n >= output_size
+ and (n - 1) * stride + kernel_size == input_size
+ ):
+ q = conv_chain(n, output_size, remain_depth - 1, cond)
+ r += [[(kernel_size, stride)] + u for u in q]