def _to_patches(self, X):
        """
        Reshapes input to patches of the size of classifier's receptive field.

        For example:

        input X shape: [n_samples, n_pixels_y, n_pixels_x, n_bands]

        output: [n_samples * n_pixels_y/receptive_field_y * n_pixels_x/receptive_field_x,
                 receptive_field_y, receptive_field_x, n_bands]
        """

        window = self.receptive_field
        asteps = self.receptive_field

        if len(X.shape) == 4:
            window += (0,)
            asteps += (1,)

        image_view = rolling_window(X, window, asteps)

        new_shape = image_view.shape

        # this makes a copy of the array? can we do without reshaping?
        image_view = image_view.reshape((new_shape[0] * new_shape[1] * new_shape[2],) + new_shape[3:])

        if len(X.shape) == 4:
            image_view = np.moveaxis(image_view, 1, -1)

        return image_view, new_shape
def _to_patches ( self , X ) : window = self . receptive_field asteps = self . receptive_field if len ( X . shape ) == 4 : window += ( 0 , ) asteps += ( 1 , ) image_view = rolling_window ( X , window , asteps ) new_shape = image_view . shape image_view = image_view . reshape ( ( new_shape [ 0 ] * new_shape [ 1 ] * new_shape [ 2 ] , ) + new_shape [ 3 : ] ) if len ( X . shape ) == 4 : image_view = np . moveaxis ( image_view , 1 , - 1 ) return image_view , new_shape
Reshapes input to patches of the size of classifier's receptive field.

        For example:

        input X shape: [n_samples, n_pixels_y, n_pixels_x, n_bands]

        output: [n_samples * n_pixels_y/receptive_field_y * n_pixels_x/receptive_field_x,
                 receptive_field_y, receptive_field_x, n_bands]