def __init__(self, model_dir, model_name=None, num_classes=None): self.time_dir = model_dir self.num_classes = num_classes self.__model_dir = mkdir_time(PATH_MODEL_DIR, model_dir) self.__update_model_dir = mkdir_time(PATH_MODEL_DIR, NEW_TIME_DIR) self.__monitor_bigger_best = self.params['monitor_mode'] == 'max' # initialize some variables that would be used by func "model.fit"; # the child class can change this params when customizing the build func self.__class_weight = None self.__initial_epoch = 0 if 'initial_epoch' not in self.params else self.params[ 'initial_epoch'] # get the tensorboard dir path self.__get_tf_board_path(model_dir) # get the model path self.__get_model_path(model_name) self.init_gpu_config() # build model self.build() # initialize some callback funcs self.__init_callback()
def __init__(self, model_dir, model_name=None): # get the time from model name and create a directory for this time dir_path = mkdir_time(PATH_MODEL_DIR, model_dir) self.__model_path = os.path.join( dir_path, model_name + '.model' if model_name else 'lgb.model') if model_name and os.path.isfile(self.__model_path): self.__has_train = True self.__model = lgb.Booster(model_file=self.__model_path) else: self.__has_train = False self.__model = lgb.LGBMClassifier(**self.params)
def __get_tf_board_path(self, model_dir): """ Get the tensorboard dir path and run it on cmd """ self.tf_board_dir = mkdir_time(PATH_BOARD_DIR, model_dir)