def _save_model_desc(self): search_space = SearchSpace() codec = Codec(self.cfg.codec, search_space) pareto_front_df = pd.read_csv( FileOps.join_path(self.result_path, "pareto_front.csv")) codes = pareto_front_df['Code'] for i in range(len(codes)): search_desc = Config() search_desc.custom = deepcopy(search_space.search_space.custom) search_desc.modules = deepcopy(search_space.search_space.modules) code = codes.loc[i] search_desc.custom.code = code search_desc.custom.method = 'full' codec.decode(search_desc.custom) self.trainer.output_model_desc(i, search_desc)
def _save_model_desc(self): """Save final model desc of NAS.""" pf_file = FileOps.join_path(self.trainer.local_output_path, self.trainer.step_name, "pareto_front.csv") if not FileOps.exists(pf_file): return with open(pf_file, "r") as file: pf = pd.read_csv(file) pareto_fronts = pf["encoding"].tolist() search_space = SearchSpace() codec = QuantCodec('QuantCodec', search_space) for i, pareto_front in enumerate(pareto_fronts): pareto_front = [int(x) for x in pareto_front[1:-1].split(',')] model_desc = Config() model_desc.modules = search_space.search_space.modules model_desc.backbone = codec.decode(pareto_front)._desc.backbone self.trainer.output_model_desc(i, model_desc)