(self, network, network_label, iter_label)
| 72 | return str(network), sum(map(lambda x: x.numel(), network.parameters())) |
| 73 | |
| 74 | def save_network(self, network, network_label, iter_label): |
| 75 | save_filename = '{}_{}.pth'.format(iter_label, network_label) |
| 76 | save_path = os.path.join(self.opt['path']['models'], save_filename) |
| 77 | if isinstance(network, nn.DataParallel) or isinstance(network, DistributedDataParallel): |
| 78 | network = network.module |
| 79 | state_dict = network.state_dict() |
| 80 | for key, param in state_dict.items(): |
| 81 | state_dict[key] = param.cpu() |
| 82 | torch.save(state_dict, save_path) |
| 83 | |
| 84 | def load_network(self, load_path, network, strict=True): |
| 85 | if isinstance(network, nn.DataParallel) or isinstance(network, DistributedDataParallel): |
no test coverage detected