示例#1
0
    def initSup(self, Draws=True):
        """ Function to initialize the Support vectors structures self.Support and
            self.S. Plus it preallocates L,C and B. Then fixes the non-tree edges.
            Also, initializes the Gemoetry.Basis for self.SHB (Edges are computed)
            REQUIRES THE ANNOTATION TO HAVE BEEN COMPUTED!
        """
        self.S = np.eye(self.dimH1, dtype=np.int64)
        for i in range(self.dimH1):
            self.Support.append(self.S[:, i])

        # init the matrices
        self.L = np.zeros((self.dimH1, len(self.Sentinel)), dtype=np.int64)
        self.C = np.zeros((len(self.Sentinel), self.dimH1), dtype=np.int64)
        self.B = np.zeros((self.dimH1, self.dimH1), dtype=np.int64)

        # compute labels as a starter
        for i in range(self.dimH1):
            for j in range(len(self.Sentinel)):
                ann = self.AnnDict[self.Sentinel[j]]
                self.L[i, j] = self.innerProd(self.S[:, i], ann)

        # fix non-tree edges as we need them for the base case
        _ = self.fixNTE()

        # FIND A FILTER BETWEEN EDGES AND SENTINEL EDGES
        Filter = np.array([1 if (x in self.Sentinel) else 0 for x in self.Edges])
        self.SentFilter = np.nonzero(Filter)

        # Let us initialize the variable self.SHB as a class Basis object of the
        # Geometry module

        self.SHB = Geometry.Basis(self.NEdges, edgelist=self.Edges)

        self.allDraws = Draws