pass else: try: pretrained_model = torch.load('./Encoders/' + args.model_id + '.pt') try: netE.load_state_dict(pretrained_model.state_dict()) except: netE.load_state_dict(pretrained_model) except: print('Encoder weight not match, random init') # Print the model print(netE) # Create the decoder netDec = Decoder(args).to(device) # Handle multi-gpu if desired if (device.type == 'cuda') and (args.ngpu > 1): netDec = nn.DataParallel(netDec, list(range(args.ngpu))) # Apply the weights_init function to randomly initialize all weights # to mean=0, stdev=0.2. if args.model_id is 'default': netDec.apply(weights_init) pass else: try: pretrained_model = torch.load('./Decoders/' + args.model_id + '.pt') try: netDec.load_state_dict(pretrained_model.state_dict())