'Compute the Principal Component.'

def _compute_global_pc(self, dataset, session, limit=None):

    _dataset = dataset
    if isinstance(limit, int):
        _dataset = _dataset[:limit]
    d = _dataset
    (s0, s1, s2, s3) = (d.shape[0], d.shape[1], d.shape[2], d.shape[3])
    flat = np.reshape(d, (s0, ((s1 * s2) * s3)))
    sigma = (np.dot(flat.T, flat) / flat.shape[1])
    (U, S, V) = np.linalg.svd(sigma)
    pc = np.dot(np.dot(U, np.diag((1.0 / np.sqrt((S + _EPSILON))))), U.T)
    self.global_pc.assign(pc, session)
    return pc
