def train(self, X, mean=None):
        warnings.warn('You should probably be using SparseMatPCA, '
                      'unless your design matrix fits in memory.')

        n, d = X.shape
        # Can't subtract a sparse vector from a sparse matrix, apparently,
        # so here I repeat the vector to construct a matrix.
        mean = X.mean(axis=0)
        mean_matrix = csr_matrix(mean.repeat(n).reshape((d, n))).T
        X = X - mean_matrix

        super(SparsePCA, self).train(X, mean=numpy.asarray(mean).squeeze())
.. todo::
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/models/pca.py/SparsePCA.train