def transform(self, X):
        X = check_tensor(X, dtype=np.float32, n_dim=4)
        if self.batch_size is None:
            if self.force_reshape:
                return self.transform_function(X.transpose(
                        *self.transpose_order))[0].reshape((len(X), -1))
            else:
                return self.transform_function(
                    X.transpose(*self.transpose_order))
        else:
            XT = X.transpose(*self.transpose_order)
            n_samples = XT.shape[0]
            for i in range(0, n_samples, self.batch_size):
                transformed_batch = self.transform_function(
                    XT[i:i + self.batch_size])
                # at first iteration, initialize output arrays to correct size
                if i == 0:
                    shapes = [(n_samples,) + t.shape[1:] for t in
                              transformed_batch]
                    ravelled_shapes = [np.prod(shp[1:]) for shp in shapes]
                    if self.force_reshape:
                        output_width = np.sum(ravelled_shapes)
                        output = np.empty((n_samples, output_width),
                                          dtype=transformed_batch[0].dtype)
                        break_points = np.r_([0], np.cumsum(ravelled_shapes))
                        raw_output = [
                            output[:, start:stop] for start, stop in
                            zip(break_points[:-1], break_points[1:])]
                    else:
                        output = [np.empty(shape,
                                           dtype=transformed_batch.dtype)
                                  for shape in shapes]
                        raw_output = [arr.reshape(n_samples, -1)
                                      for arr in output]

                for transformed, out in zip(transformed_batch, raw_output):
                    out[i:i + batch_size] = transformed
        return output
Transform a set of images.
dataset/ETHPy150Open sklearn-theano/sklearn-theano/sklearn_theano/feature_extraction/overfeat.py/OverfeatTransformer.transform