def subpixel(x, out_channels=1):
    """Unfold channel/depth dimensions to enlarge the feature map
    Notice: Output size is deducted. 
    The size of the unfold square is automatically determined
    e.g. :
        images: 100x9x16x16.  9=3x3 square
        subpixel-out: 100x1x48x48
    Arguement:
        x: NCHW image, channel first.
        out_channels, channel number of output feature map"""
    b, c, h, w = shapes = list(x.shape)
    out_c = int(out_channels)
    if c % out_c != 0:
        print('input has', c, 'channels, cannot be split into', out_c, 'parts')
        raise Exception('subpixel inappropriate size')
    unfold_dim = int(c // out_c)
    l = int(unfold_dim ** 0.5)
    if l ** 2 != unfold_dim:
        print('remaining', unfold_dim,
            'digits for each channel, unable to sqrt.')
        raise Exception('subpixel inappropriate size %f**2 != %d' % (l, int
            (unfold_dim)))
    x = x.transpose(1, 3)
    y = x.reshape(b, h, w, unfold_dim, out_c)
    y = y.transpose(2, 3)
    y = y.reshape(b, h, l, l, w, out_c)
    y = y.reshape(b, l * h, l, w, out_c)
    y = y.transpose(2, 3)
    y = y.reshape(b, l * h, l * w, out_c)
    y = y.transpose(1, 3)
    return y
