Split image tensor into small patches
问题 I have an image of shape (466,394,1) which I want to split into 7x7 patches. image = tf.placeholder(dtype=tf.float32, shape=[1, 466, 394, 1]) Using image_patches = tf.extract_image_patches(image, [1, 7, 7, 1], [1, 7, 7, 1], [1, 1, 1, 1], 'VALID') # shape (1, 66, 56, 49) image_patches_reshaped = tf.reshape(image_patches, [-1, 7, 7, 1]) # shape (3696, 7, 7, 1) unfortunately does not work in practice as image_patches_reshaped mixes up the pixel order (if you view images_patches_reshaped you will