Exemplo n.º 1
0
    def __init__(self,
                 sModelName,
                 sModelDir,
                 sComment=None,
                 cFeatureDefinition=None,
                 dFeatureConfig={}):

        super().__init__(sModelName,
                         sModelDir,
                         sComment=sComment,
                         cFeatureDefinition=cFeatureDefinition,
                         dFeatureConfig=dFeatureConfig)

        # Dynamic import
        global Model_SSVM_AD3, Model_SSVM_AD3_Multitype
        Model_SSVM_AD3 = DU_Task.DYNAMIC_IMPORT('.Model_SSVM_AD3',
                                                'crf').Model_SSVM_AD3
        Model_SSVM_AD3_Multitype = DU_Task.DYNAMIC_IMPORT(
            '.Model_SSVM_AD3_Multitype', 'crf').Model_SSVM_AD3_Multitype

        if self.iNbNodeType > 1:
            #check the configuration of a MULTITYPE graph
            setKeyGiven = set(dFeatureConfig.keys())
            lNT = self.cGraphClass.getNodeTypeList()
            setKeyExpected = {nt.name
                              for nt in lNT}.union({
                                  "%s_%s" % (nt1.name, nt2.name)
                                  for nt1 in lNT for nt2 in lNT
                              })

            setMissing = setKeyExpected.difference(setKeyGiven)
            setExtra = setKeyGiven.difference(setKeyExpected)
            if setMissing:
                traceln("ERROR: missing feature extractor config for : ",
                        ", ".join(setMissing))
            if setExtra:
                traceln("ERROR: feature extractor config for unknown : ",
                        ", ".join(setExtra))
            if setMissing or setExtra:
                raise ValueError(
                    "Bad feature extractor configuration for a multi-type CRF graph"
                )

        self.cModelClass = Model_SSVM_AD3 if self.iNbNodeType == 1 else Model_SSVM_AD3_Multitype
        assert issubclass(
            self.cModelClass, graph.GraphModel.GraphModel
        ), "Your model class must inherit from graph.GraphModel.GraphModel"
Exemplo n.º 2
0
    def __init__(self, sModelName, sModelDir
                 , sComment             = None
                 , cFeatureDefinition   = None
                 , dFeatureConfig       = {}
                 , cModelClass          = None
                 ):
        super().__init__(sModelName, sModelDir, sComment, cFeatureDefinition, dFeatureConfig)

        global DU_Model_GAT
        DU_Model_GAT = DU_Task.DYNAMIC_IMPORT('.DU_Model_ECN', 'gcn').DU_Model_GAT
        
        self.cModelClass = DU_Model_GAT if cModelClass == None else cModelClass
        assert issubclass(self.cModelClass, graph.GraphModel.GraphModel), "Your model class must inherit from graph.GraphModel.GraphModel"
Exemplo n.º 3
0
 def getVersion(cls):
     cls.version = "-".join([DU_Task.getVersion(), str(cls.VERSION)])
     return cls.version