Solved by ptrblck in post #4 
              
              
                The used padding is too naive in my example and you might want to use e.g. divmod to calculate the padding size: 
def unfold_tensor (x, step_c, step_h, step_w):
    kc, kh, kw = step_c, step_h, step_w  # kernel size
    dc, dh, dw = step_c, step_h, step_w  # stride
    
    nc, remainder = np.divmod…