(self, args)
| 678 | pin_memory=False, sampler=self.test_sampler, collate_fn=collate) |
| 679 | |
| 680 | def load(self, args): |
| 681 | if args.load_path == '': |
| 682 | return |
| 683 | load_path = args.load_path if args.load_single else args.load_path.replace('ckpt_task_', f'ckpt_task{self.ginfo.task_id}_') |
| 684 | |
| 685 | try: |
| 686 | checkpoint = torch.load(load_path, 'cpu') |
| 687 | except: |
| 688 | raise FileNotFoundError(f'=> no checkpoint found at {load_path}') |
| 689 | |
| 690 | if self.ginfo.task_rank == 0: |
| 691 | printlog(f"Recovering from {load_path}, keys={list(checkpoint.keys())}") |
| 692 | |
| 693 | if 'state_dict' in checkpoint: |
| 694 | pretrained_state_dict = checkpoint['state_dict'] |
| 695 | else: |
| 696 | pretrained_state_dict = checkpoint |
| 697 | |
| 698 | ignores = args.ignore + self.config.get('load_ignore', []) |
| 699 | if len(ignores) > 0: |
| 700 | for k in list(pretrained_state_dict.keys()): |
| 701 | flag = False |
| 702 | for prefix in ignores: |
| 703 | if k.startswith(prefix): |
| 704 | flag = True |
| 705 | the_prefix = prefix |
| 706 | break |
| 707 | if flag: |
| 708 | print('ignoring {} (prefix: {})'.format(k, the_prefix)) |
| 709 | del pretrained_state_dict[k] |
| 710 | load_state_model(self.model, pretrained_state_dict, self.ginfo) |
| 711 | |
| 712 | def prepare_data(self): |
| 713 | self.tmp.input_var = dict() |
no test coverage detected