def test_ompMask():
    np.random.seed(0)
    print('test ompMask')

    ########################################
    # Decomposition of a large number of signals
    ########################################
    X = np.asfortranarray(np.random.normal(size=(300, 300)))
    X = np.asfortranarray(X / np.tile(np.sqrt((X * X).sum(axis=0)),
                                      (X.shape[0], 1)),
                          dtype=myfloat)
    D = np.asfortranarray(np.random.normal(size=(300, 50)))
    D = np.asfortranarray(D / np.tile(np.sqrt((D * D).sum(axis=0)),
                                      (D.shape[0], 1)),
                          dtype=myfloat)
    mask = np.asfortranarray((X > 0))  # generating a binary mask
    L = 20
    eps = 0.1
    numThreads = -1
    tic = time.time()
    alpha = spams.ompMask(X,
                          D,
                          mask,
                          L=L,
                          eps=eps,
                          return_reg_path=False,
                          numThreads=numThreads)
    tac = time.time()
    t = tac - tic
    print("%f signals processed per second\n" % (float(X.shape[1]) / t))

    return None
Example #2
0
    def _transform_omp(self, X, mask):
        """
        Performs the OMP transformation.
        
        :param X: Input data. See `.fit` for more information.
        :param mask: Mask on input data. See `.fit` for more information.
        :return: Reconstruction parameters
        """

        if mask is None:
            return spams.omp(**self.omp_params(X)).T

        return spams.ompMask(
            X=np.asfortranarray(X.T),
            D=np.asfortranarray(self.dictionary),
            B=np.asfortranarray(mask.T),
            L=self.l0_max,
            lambda1=self.l1_reconstruct,
            numThreads=2,
        ).T
Example #3
0
def test_ompMask():
    np.random.seed(0)
    print('test ompMask')

########################################
# Decomposition of a large number of signals
########################################
    X = np.asfortranarray(np.random.normal(size=(300,300)))
    X = np.asfortranarray(X / np.tile(np.sqrt((X*X).sum(axis=0)),(X.shape[0],1)),dtype= myfloat)
    D = np.asfortranarray(np.random.normal(size=(300,50)))
    D = np.asfortranarray(D / np.tile(np.sqrt((D*D).sum(axis=0)),(D.shape[0],1)),dtype= myfloat)
    mask = np.asfortranarray((X > 0))  # generating a binary mask
    L = 20
    eps = 0.1
    numThreads=-1
    tic = time.time()
    alpha = spams.ompMask(X,D,mask,L = L,eps = eps,return_reg_path = False,numThreads = numThreads)
    tac = time.time()
    t = tac - tic
    print("%f signals processed per second\n" %(float(X.shape[1]) / t))

    return None