def map_to_vectors(self, x, d=None, theta_max=np.pi / 2):
     if d is None:
         d = self.d
     x *= theta_max
     y = np.zeros((self.d, ) + x.shape)
     for nd in range(1, self.d + 1):
         y[nd - 1, :, :] = (np.sqrt(tm.combination(d - 1, nd - 1)) *
                            (np.cos(x)**(d - nd)) * (np.sin(x)**(nd - 1)))
     return y
Beispiel #2
0
 def multiple_images2vecs(self, theta_max=np.pi/2):
     # Put the data of images in self.tmp!!!
     # The pixels should have been normalized to [0, 1)
     s = self.tmp.shape
     self.tmp *= theta_max
     self.vecsImages = np.zeros((self.d, ) + s)
     for nd in range(1, self.d+1):
         self.vecsImages[nd-1, :, :] = (np.sqrt(tm.combination(self.d-1, nd-1)) * (
                 np.cos(self.tmp)**(self.d-nd)) * (np.sin(self.tmp)**(nd-1)))
 def images2vecs(self, theta_max=np.pi / 2):
     # The pixels should have been normalized to [0, 1)
     s = self.images.shape
     self.numVecSample = s[1]
     self.images *= theta_max
     self.vecsImages = np.zeros((self.d, ) + s)
     for nd in range(1, self.d + 1):
         self.vecsImages[nd - 1, :, :] = (
             np.sqrt(tm.combination(self.d - 1, nd - 1)) *
             (np.cos(self.images)**(self.d - nd)) *
             (np.sin(self.images)**(nd - 1)))