(self)
| 240 | return res |
| 241 | |
| 242 | def search(self): |
| 243 | print( |
| 244 | 'population_num = {} select_num = {} mutation_num = {} crossover_num = {} random_num = {} max_epochs = {}'.format( |
| 245 | self.population_num, self.select_num, self.mutation_num, self.crossover_num, |
| 246 | self.population_num - self.mutation_num - self.crossover_num, self.max_epochs)) |
| 247 | |
| 248 | # self.load_checkpoint() |
| 249 | |
| 250 | self.get_random(self.population_num) |
| 251 | |
| 252 | while self.epoch < self.max_epochs: |
| 253 | print('epoch = {}'.format(self.epoch)) |
| 254 | |
| 255 | self.memory.append([]) |
| 256 | for cand in self.candidates: |
| 257 | self.memory[-1].append(cand) |
| 258 | |
| 259 | self.update_top_k( |
| 260 | self.candidates, k=self.select_num, key=lambda x: self.vis_dict[x]['acc']) |
| 261 | self.update_top_k( |
| 262 | self.candidates, k=50, key=lambda x: self.vis_dict[x]['acc']) |
| 263 | |
| 264 | print('epoch = {} : top {} result'.format( |
| 265 | self.epoch, len(self.keep_top_k[50]))) |
| 266 | tmp_accuracy = [] |
| 267 | for i, cand in enumerate(self.keep_top_k[50]): |
| 268 | print('No.{} {} Top-1 val acc = {}, Top-1 test acc = {}, params = {}'.format( |
| 269 | i + 1, cand, self.vis_dict[cand]['acc'], self.vis_dict[cand]['test_acc'], self.vis_dict[cand]['params'])) |
| 270 | tmp_accuracy.append(self.vis_dict[cand]['acc']) |
| 271 | self.top_accuracies.append(tmp_accuracy) |
| 272 | |
| 273 | mutation = self.get_mutation( |
| 274 | self.select_num, self.mutation_num, self.m_prob, self.s_prob) |
| 275 | crossover = self.get_crossover(self.select_num, self.crossover_num) |
| 276 | |
| 277 | self.candidates = mutation + crossover |
| 278 | |
| 279 | self.get_random(self.population_num) |
| 280 | |
| 281 | self.epoch += 1 |
| 282 | |
| 283 | self.save_checkpoint() |
| 284 | |
| 285 | def get_args_parser(): |
| 286 | parser = argparse.ArgumentParser('DeiT training and evaluation script', add_help=False) |
no test coverage detected