print(network_repr) writer.add_text('general', network_repr) if args.model == 'unconstrained': for module in network.modules(): if hasattr(module, 'relax'): module.relax() print(f'relaxing {repr(module)}') network_repr = repr(network) print(network_repr) writer.add_text('general', network_repr) n_params = 0 for param in network.parameters(): n_params += param.numel() print(n_params, 'learnable parameters') if cuda: network = network.cuda() checkpoint = framework.load_checkpoint(args.model_path) start_epoch, best_score, model_dict, optim_dict = checkpoint network.load_state_dict(model_dict) framework.inspect(network, val_loader, args.artifacts, early_stop=args.early_stop)
loss_fn.name = 'BCE' optim = torch.optim.Adam([ { 'params': network.l2_params(), 'weight_decay': args.l2 }, { 'params': network.nr_params(), 'weight_decay': 0. }, ], lr=args.lr) if args.load: checkpoint = framework.load_checkpoint(args.load) start_epoch, best_score, model_dict, optim_dict = checkpoint network.load_state_dict(model_dict) optim.load_state_dict(optim_dict) fmt = 'Starting at epoch {}, best score {}. Loaded from {}' start_epoch += 1 # skip to the next after loaded msg = fmt.format(start_epoch, best_score, args.load) else: print('Set start epoch and best score to 0') best_score = 0. start_epoch = 0 if args.model == 'unconstrained': for module in network.modules(): if hasattr(module, 'relax'):