def norm_stdev(self): if self.color_mode == "rgb" or self.color_mode == "hsv": stdev_chan1 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_stdev_chan1"), self._normalize_stdev[0]) stdev_chan2 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_stdev_chan2"), self._normalize_stdev[1]) stdev_chan3 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_stdev_chan3"), self._normalize_stdev[2]) return np.array([stdev_chan1, stdev_chan2, stdev_chan3]) elif self.color_mode == "grayscale": grayscale_stdev = np.mean(self._normalize_stdev) return assign_fallback( self.cp[self.SECTION].getfloat("normalize_stdev"), grayscale_stdev)
def norm_mean(self): if self.color_mode == "rgb" or self.color_mode == "hsv": mean_chan1 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_mean_chan1"), self._normalize_mean[0]) mean_chan2 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_mean_chan2"), self._normalize_mean[1]) mean_chan3 = assign_fallback( self.cp[self.SECTION].getfloat("normalize_mean_chan3"), self._normalize_mean[2]) return np.array([mean_chan1, mean_chan2, mean_chan3]) elif self.color_mode == "grayscale": grayscale_mean = np.mean(self._normalize_mean) return assign_fallback( self.cp[self.SECTION].getfloat("normalize_mean"), grayscale_mean)
def __init__(self, cp): super().__init__(cp=cp) self._initial_learning_rate = assign_fallback( self.cp["TRAIN"].getfloat("initial_learning_rate"), self._initial_learning_rate) config_train_steps = self.cp["TRAIN"].get("train_steps") if config_train_steps != "auto" and config_train_steps is not None: try: config_train_steps = int(config_train_steps) except ValueError: raise ValueError( "** train_steps: {} is invalid,please use 'auto' or integer." .format(config_train_steps)) else: config_train_steps = None config_validation_steps = assign_fallback( self.cp["TRAIN"].get("validation_steps"), self._validation_steps) if config_validation_steps != "auto" and config_validation_steps is not None: try: config_validation_steps = int(config_validation_steps) except ValueError: raise ValueError( "** validation_steps: {} is invalid,please use 'auto' or integer." .format(config_validation_steps)) else: config_validation_steps = None config_test_steps = assign_fallback(self.cp["TEST"].get("steps"), self._test_steps) if config_test_steps != "auto" and config_test_steps is not None: try: config_test_steps = int(config_test_steps) except ValueError: raise ValueError( "** test_steps: {} is invalid,please use 'auto' or integer." .format(config_test_steps)) else: config_test_steps = None self._train_steps = assign_fallback(config_train_steps, self._train_steps) self._validation_steps = assign_fallback(config_validation_steps, self._validation_steps) self._test_steps = assign_fallback(config_test_steps, self._test_steps)
def gpu(self): return assign_fallback(self.cp["TRAIN"].getint("gpu"), self._gpu)
def verbosity(self): return assign_fallback(self.cp["DEFAULT"].getint("verbosity"), self._verbosity)
def model_name(self): return assign_fallback(self.cp[self.SECTION].get("model_name"), self._model_name)
def random_state(self): return assign_fallback( self.cp["DATASET"].getint("split_dataset_random_state"), self._random_state)
def dev_augmentation(self): return assign_fallback( self.cp[self.SECTION].getboolean("dev_augmentation"), self._dev_augmentation)
def random_vert_flip(self): return assign_fallback( self.cp[self.SECTION].getboolean("random_vert_flip"), self._random_vert_flip)
def histogram_freq(self): return assign_fallback(self.cp["TRAIN"].getint("histogram_freq"), self._histogram_freq)
def scale(self): return assign_fallback(self.cp["IMAGE"].getfloat("scale"), self._scale)
def progress_test_verbosity(self): return assign_fallback(self.cp["TEST"].getint("progress_verbosity"), self._progress_verbosity)
def enable_grad_cam(self): return assign_fallback(self.cp["TEST"].getboolean("enable_grad_cam"), self._enable_grad_cam)
def progress_train_verbosity(self): return assign_fallback(self.cp["TRAIN"].getint("progress_verbosity"), self._progress_verbosity)
def color_mode(self): return assign_fallback(self.cp["IMAGE"].get("color_mode"), self._color_mode)
def final_activation(self): return assign_fallback(self.cp["DATASET"].get("final_activation"), self._final_activation)
def epochs(self): return assign_fallback(self.cp["TRAIN"].getint("epochs"), self._epochs)
def write_graph(self): return assign_fallback(self.cp["TRAIN"].getboolean("write_graph"), self._write_graph)
def img_dim(self): return assign_fallback(self.cp["IMAGE"].getint("image_dimension"), self._img_dim)
def write_images(self): return assign_fallback(self.cp["TRAIN"].getboolean("write_images"), self._write_images)
def train_augmentation(self): return assign_fallback( self.cp[self.SECTION].getboolean("train_augmentation"), self._train_augmentation)
def embeddings_freq(self): return assign_fallback(self.cp["TRAIN"].getint("embeddings_freq"), self._embeddings_freq)
def flip_prob(self): return assign_fallback(self.cp[self.SECTION].getfloat("flip_prob"), self._flip_prob)
def use_best_weights(self): return assign_fallback(self.cp[self.SECTION].getboolean("use_best_weights"), self._use_trained_model_weights)
def __init__(self, cp): super().__init__(cp) self._use_trained_model_weights = assign_fallback(self.cp[self.SECTION].getboolean("use_trained_model_weights"), self._use_trained_model_weights)
def use_class_balancing(self): return assign_fallback( self.cp["DATASET"].getboolean("use_class_balancing"), self._use_class_balancing)
def use_ext_base_model_weights(self): return assign_fallback(self.cp[self.SECTION].getboolean("use_ext_base_model_weights"), self._use_ext_base_model_weights)
def use_default_split(self): return assign_fallback( self.cp["DATASET"].getboolean("use_default_split"), self._use_default_split)
def show_model_summary(self): return assign_fallback(self.cp[self.SECTION].getboolean("show_model_summary"), self._show_model_summary)
def patience_reduce_lr(self): return assign_fallback(self.cp["TRAIN"].getint("patience_reduce_lr"), self._patience_reduce_lr)