

def make_patches_grid(x, patch_size, patch_stride):
    'Break image `x` up into a grid of patches.\n\n    input shape: (channels, rows, cols)\n    output shape: (rows, cols, channels, patch_rows, patch_cols)\n    '
    from theano.tensor.nnet.neighbours import images2neibs
    x = K.expand_dims(x, 0)
    xs = K.shape(x)
    num_rows = (1 + ((xs[(- 2)] - patch_size) // patch_stride))
    num_cols = (1 + ((xs[(- 1)] - patch_size) // patch_stride))
    num_channels = patch_size[(- 3)]
    patches = images2neibs(x, (patch_size, patch_size), (patch_stride, patch_stride), mode='valid')
    patches = K.reshape(patches, (num_channels, (K.shape(patches)[0] // num_channels), patch_size, patch_size))
    patches = K.permute_dimensions(patches, (1, 0, 2, 3))
    patches = K.reshape(patches, (num_rows, num_cols, num_channels, patch_size, patch_size))
    patches_norm = K.sqrt(K.sum(K.square(patches), axis=(2, 3, 4), keepdims=True))
    return (patches, patches_norm)

dataset/ETHPy150Open awentzonline/image-analogies/image_analogy/losses/mrf.py make_patches_grid/VarMisuse@93/188 `xs`->`patch_size`