def get_train_configured_instance_operation(self, cfg_fname=g_config_filename): """ return configured instances and operation. """ ml_instance_dict = dict() ml_enable_list = [] train_oper_dict = dict() # key : first_ml, second_ml, .... value : operation unit list config = cp.ConfigParser() config.read(cfg_fname) # self.ml_num = int(config['ML_Process']['ml_num']) # self.ml_name_list = config['ML_Process']['ml_names'] \ # .replace(' ','').split(',') # every ml config section gets machine learning class instance for section, entries in config.items() : try : if section.split('_')[1] == 'ML' and entries['enable'] == 'true': ml_enable_list.append(section.lower()) ml_instance = get_classes.class_dict[entries['ML_NAME']]() # get class instance ml_instance.set_config(ml_instance, section_num = section[0], arg_dict = entries) # set each config ml_instance.set_proper_config_type() ml_instance_dict[section.lower()] = ml_instance # section.lower() = 1st_ML, 2nd_ML, ... # when the machine learning written in config file doesn't exist, exception process is needed. except IndexError: pass # get train_operations assing func as according to their type train_operations_dict = config['Train_Operations'] # key:1st_ml; value:create, train, .. for ml_order, train_operations_str in train_operations_dict.items(): if ml_order in ml_enable_list: train_operations_list = train_operations_str.replace(' ', '').split(',') train_oper_dict[ml_order.lower()] = [] for oper in train_operations_list: train_oper_dict[ml_order.lower()].append(op.operation_unit(oper)) # set each operation and input path as operation_unit return (ml_instance_dict, train_oper_dict)
def config(self, config_fname='config'): config = cp.ConfigParser() config.read(config_fname) self.model_num = int(config['ML_Process']['model_num']) self.model_name_list = config['ML_Process']['model_names'] \ .replace(' ','').split(',') for section, entries in config.items(): # get model instance try: if section.split( '_')[1] == 'MODEL' and entries['enable'] == 'true': # print(items['model_name']) model = library.class_obj_dict[entries['model_name']]() model.set_config(arg_dict=entries) self.model_dict[section.lower()] = model # config 파일에 적힌 모델이 없는 경우에 대한 예외 처리 필요 except IndexError: pass predict_operations_list = config['Predict_operations']['predict_operations'] \ .replace(' ', '').split(',') for oper in predict_operations_list: self.predict_oper_list.append(op.operation_unit(oper)) train_operations_dict = config[ 'Train_operations'] # key : first_model value : D:"", T"", O"" ... for model_order, train_operations_str in train_operations_dict.items(): train_operations_list = train_operations_str.replace(' ', '').split(',') self.train_oper_dict[model_order] = [] for oper in train_operations_list: self.train_oper_dict[model_order].append( op.operation_unit(oper)) self.print_config_all()