def get(self, request, nnid):
        """
        Manage AutoML define information include (id, desc and etc ) \n
        Structure : AutoML - NetID - NetVer(Auto Generated by GA) - NetBatch (auto generated on every batch) \n
        (1) Define AutoML Graph definition \n
        (2) Select Type of Data \n
        (3) Select Type of Anal algorithm \n
        (4) Select range of hyper parameters \n
        (5) Run - AutoML \n
        (6) Check result of each generation with UI/UX (<- for this step) \n
        (7) Select Best model you want use and activate it \n
        ---
        # Class Name : RunManagerAutoStat

        # Description:
            Get Result of Train for each population
        """
        try:
            aml = AutoMlCommon(nnid)
            stat_info = aml.get_stat_obj(nnid)
            return_data = stat_info
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))
    def get(self, request, nnid):
        """
        Manage AutoML define information include (id, desc and etc ) \n
        Structure : AutoML - NetID - NetVer(Auto Generated by GA) - NetBatch (auto generated on every batch) \n
        (1) Define AutoML Graph definition \n
        (2) Select Type of Data \n
        (3) Select Type of Anal algorithm \n
        (4) Select range of hyper parameters \n
        (5) Run - AutoML \n
        (6) Check result of each generation with UI/UX (<- for this step) \n
        (7) Select Best model you want use and activate it \n
        ---
        # Class Name : RunManagerAutoStat

        # Description:
            Get Result of Train for each population
        """
        try:
            aml = AutoMlCommon(nnid)
            stat_info  = aml.get_stat_obj(nnid)
            return_data = stat_info
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))
 def save_summary(self, info):
     """
     save best survived results
     :return:
     """
     self.summary['best'] = info
     AutoMlCommon().update_stat_obj(self.nn_id, self.summary)
Exemple #4
0
 def __init__(self, nn_id):
     """
     initialize parms need to run auto mode
     :return:
     """
     self.auto_ml_info = AutoMlCommon(nn_id)
     self.conf_info = self.auto_ml_info.conf_info
     self.train_info = self.auto_ml_info.train_info
     self.stat_info = self.auto_ml_info.stat_info
 def put(self, request, nnid):
     """
     - desc ; update cnn configuration data
     """
     try:
         return_data = AutoMlCommon().update_conf_obj(nnid, request.data)
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "404", "result": str(e)}
         return Response(json.dumps(return_data))
 def __init__(self, nn_id):
     """
     initialize parms need to run auto mode
     :return:
     """
     self.nn_id = nn_id
     self.auto_ml_info = AutoMlCommon(nn_id)
     self.conf_info = self.auto_ml_info.conf_info
     self.parm_info = self.auto_ml_info.parm_info
     self.stat_info = self.auto_ml_info.stat_info
     self.net_type = self.auto_ml_info.net_type
     self.summary = {}
     self.summary['bygen'] = []
     self.summary['best'] = []
     self.celery_flag = settings.CELERY_FLAG
Exemple #7
0
 def __init__(self, nn_id):
     """
     initialize parms need to run auto mode
     :return:
     """
     self.nn_id = nn_id
     self.auto_ml_info = AutoMlCommon(nn_id)
     self.conf_info = self.auto_ml_info.conf_info
     self.parm_info = self.auto_ml_info.parm_info
     self.stat_info = self.auto_ml_info.stat_info
     self.net_type = self.auto_ml_info.net_type
     self.summary = {}
     self.summary['bygen'] = []
     self.summary['best'] = []
     self.debug_mode = False
    def run(self):
        """
        run automl
        :return:
        """
        try:
            # get genetic algorithm hyper parameters
            generation = self.parm_info.get('generation')
            population = self.parm_info.get('population')
            survive = self.parm_info.get('survive')

            # define gene list
            networks = []

            # iterate generation
            for idx in range(generation):
                # create new generations
                if (idx == 0):
                    gen_nets, ver_data_sets = self.create_networks(
                        idx, population)
                    networks = networks + gen_nets
                    AutoMlCommon().reset_stat_obj(self.nn_id)
                else:
                    gen_nets, ver_data_sets = self.create_networks(
                        idx, population - survive)
                    networks = networks + gen_nets

                # train & evaluate networks
                initial = True if idx == 0 else False
                networks = self.train_networks(networks, initial=initial)
                # set each train set flag to fin
                self.set_train_finish(ver_data_sets)
                # network acc set
                accArr = 0
                for net in networks:
                    return_data = NNCommonManager().get_nn_batch_info(
                        net['nn_id'], net['nn_wf_ver_id'])
                    re_acc = return_data[0]['acc_info']['acc']
                    networks[accArr]['acc'] = float(re_acc[len(re_acc) - 1])
                    accArr += 1
                    # print(return_data)
                # update traing progress
                self.update_summary(networks, survive)
                # sort & discard
                networks = self.discard_inferior(networks, survive)
            return networks
        except Exception as e:
            logging.error("Error on running AutoML alogorithm : {0}".format(e))
Exemple #9
0
    def put(self, request, nnid):
        """
        Your docs
        ---
        # Class Name (must be separated by `---`)

        # Description:
            - name: name
              description: Foobar long description goes here
        """
        try:
            return_data = AutoMlCommon().update_conf_obj(nnid, request.data)
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))
    def update_summary(self, networks, survive):
        """
        update summary info of processing genetic algorithm
        arranged by generation (sequece of list means number of generation
        each node contains extra info like survive or not 
        :param networks: networks for one generations
        :param survive: number of gene to survive 
        :return: dict type result info with extra flag 
        """

        # Regression sorting order add
        if self.net_type.rfind("_reg") != -1:
            networksNew = copy.deepcopy(
                sorted(networks, key=lambda x: x.get('acc'), reverse=False))
        else:
            networksNew = copy.deepcopy(
                sorted(networks, key=lambda x: x.get('acc'), reverse=True))
        # result = list(map(lambda x : self.set_value(x, 'survive', True) , networks[0:survive]))
        # self.summary['best'] = result
        # result = result + list(map(lambda x : self.set_value(x, 'survive', False) , networks[survive:]))
        # self.summary['bygen'].append(result)
        surcnt = 1
        result = []
        best = []
        for net in networksNew:
            if survive < surcnt:
                net['survive'] = False
            else:
                net['survive'] = True
                best.append(net)
            if survive == surcnt:
                self.summary['best'] = best
            result.append(net)
            surcnt += 1
        self.summary['bygen'].append(result)

        AutoMlCommon().update_stat_obj(self.nn_id, self.summary)

        # Set Best Active
        nnCommonManager = NNCommonManager()
        input_data = {}
        input_data['active_flag'] = "Y"
        input_data['nn_wf_ver_id'] = networksNew[0].get('nn_wf_ver_id')
        nnCommonManager.update_nn_wf_info(networksNew[0].get('nn_id'),
                                          input_data)
Exemple #11
0
 def update_summary(self, networks, survive):
     """
     update summary info of processing genetic algorithm
     arranged by generation (sequece of list means number of generation
     each node contains extra info like survive or not 
     :param networks: networks for one generations
     :param survive: number of gene to survive 
     :return: dict type result info with extra flag 
     """
     networks = sorted(networks, key=lambda x: x.get('acc'), reverse=True)
     result = list(
         map(lambda x: self.set_value(x, 'survive', True),
             networks[0:survive]))
     self.summary['best'] = result
     result = result + list(
         map(lambda x: self.set_value(x, 'survive', False),
             networks[survive:]))
     self.summary['bygen'].append(result)
     AutoMlCommon().update_stat_obj(self.nn_id, self.summary)
Exemple #12
0
    def run(self):
        """
        run automl
        :return:
        """
        try:
            # get genetic algorithm hyper parameters
            generation = self.parm_info.get('generation')
            population = self.parm_info.get('population')
            survive = self.parm_info.get('survive')

            # define gene list
            networks = []

            # iterate generation
            for idx in range(generation):
                # create new generations
                if (idx == 0):
                    gen_nets, ver_data_sets = self.create_networks(
                        idx, population)
                    networks = networks + gen_nets
                    AutoMlCommon().reset_stat_obj(self.nn_id)
                else:
                    gen_nets, ver_data_sets = self.create_networks(
                        idx, population - survive)
                    networks = networks + gen_nets

                # train & evaluate networks
                networks = self.train_networks(networks)
                # set each train set flag to fin
                self.set_train_finish(ver_data_sets)
                # update traing progress
                self.update_summary(networks, survive)
                # sort & discard
                networks = self.discard_inferior(networks, survive)
            return networks
        except Exception as e:
            logging.error("Error on running AutoML alogorithm : {0}".format(e))
    def put(self, request, nnid):
        """
        Manage hyperparameter for GA algorithm like eval, population, survive etc
        Structure : AutoML - NetID - NetVer(Auto Generated by GA) - NetBatch (auto generated on every batch) \n
        (1) Define AutoML Graph definition \n
        (2) Select Type of Data \n
        (3) Select Type of Anal algorithm \n
        (4) Select range of hyper parameters (<- for this step)\n
        (5) Run - AutoML \n
        (6) Check result of each generation with UI/UX \n
        (7) Select Best model you want use and activate it \n
        ---
        # Class Name : RunManagerAutoConf

        # Description:
            Modifiy hyperparameters for genetic algorithm itself, if it is not set
            Genetic Algorithm will run with default parmas
        """
        try:
            return_data = AutoMlCommon().update_conf_obj(nnid, request.data)
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))