Пример #1
0
 def test_driver(self):
     for index in range(len(self.penalties)):
         solution_vector = np.zeros(self.dictionary.shape[1])
         feature_sign_search(self.dictionary, self.signal,
                             self.penalties[index],
                             solution=solution_vector)
         yield self.check_against_reference, solution_vector, index
         yield self.check_zerocoef_optimality_cond, solution_vector, index
         yield self.check_nonzero_optimality_cond, solution_vector, index
         yield self.check_zeros_against_reference, solution_vector, index
         yield self.check_nonzeros_against_reference, solution_vector, index
Пример #2
0
 def test_driver(self):
     for index in range(len(self.penalties)):
         solution_vector = np.zeros(self.dictionary.shape[1])
         feature_sign_search(self.dictionary,
                             self.signal,
                             self.penalties[index],
                             solution=solution_vector)
         yield self.check_against_reference, solution_vector, index
         yield self.check_zerocoef_optimality_cond, solution_vector, index
         yield self.check_nonzero_optimality_cond, solution_vector, index
         yield self.check_zeros_against_reference, solution_vector, index
         yield self.check_nonzeros_against_reference, solution_vector, index
Пример #3
0
 def test_shape_rank_matches_2d_generated(self):
     sparsity = self.penalties[0]
     signal = self.signal.reshape(1, -1)
     solution = feature_sign_search(self.dictionary, signal, sparsity)
     assert solution.ndim == 2
     assert solution.shape[0] == 1
     assert solution.shape[1] == self.dictionary.shape[1]
Пример #4
0
 def test_solution_identity_2d_provided(self):
     sparsity = self.penalties[0]
     solution = np.zeros((1, self.dictionary.shape[1]))
     signal = self.signal.reshape(1, -1)
     newsol = feature_sign_search(self.dictionary, signal, sparsity,
                                  solution=solution)
     assert solution is newsol
Пример #5
0
 def test_shape_rank_matches_2d_generated(self):
     sparsity = self.penalties[0]
     signal = self.signal.reshape(1, -1)
     solution = feature_sign_search(self.dictionary, signal, sparsity)
     assert solution.ndim == 2
     assert solution.shape[0] == 1
     assert solution.shape[1] == self.dictionary.shape[1]
Пример #6
0
 def test_solution_identity_1d_provided(self):
     sparsity = self.penalties[0]
     solution = np.zeros(self.dictionary.shape[1])
     newsol = feature_sign_search(self.dictionary,
                                  self.signal,
                                  sparsity,
                                  solution=solution)
     assert solution is newsol
    def optimize_gamma(self, example):

        #variable names chosen to follow the arguments to l1ls_featuresign

        Y = N.zeros((self.nvis,))
        Y[:] = example
        c = (1e-10 + N.square(self.W.get_value(borrow=True) -
                              example).sum(axis=1))
        A = self.W.get_value(borrow=True).T / c
        x = feature_sign_search(A, Y, self.coeff)
        g = x / c
        return g
Пример #8
0
    def optimize_gamma(self, example):

        #variable names chosen to follow the arguments to l1ls_featuresign

        Y = N.zeros((self.nvis, ))
        Y[:] = example
        c = (1e-10 +
             N.square(self.W.get_value(borrow=True) - example).sum(axis=1))
        A = self.W.get_value(borrow=True).T / c
        x = feature_sign_search(A, Y, self.coeff)
        g = x / c
        return g