args.checkpoint_dir = os.path.join(args.checkpoint_dir, args.time_id + '_' + args.identifier) args.log_dir = os.path.join(args.log_dir, args.time_id + '_' + args.identifier) print(args.__dict__) if not os.path.exists(args.checkpoint_dir) and args.log == True: os.makedirs(args.checkpoint_dir) os.makedirs(args.log_dir) model_kwargs = {'vocab': load_vocab(args.vocab_json)} shared_model = VqaLstmCnnAttentionModel(**model_kwargs) if args.checkpoint_path != False: print('Loading params from checkpoint: %s' % args.checkpoint_path) shared_model.load_state_dict(checkpoint['state']) shared_model.share_memory() fgsm(0, args, shared_model, 0) torch.cuda.empty_cache()
shared_nav_model.share_memory() print('Loading navigation params from checkpoint: %s' % args.nav_checkpoint_path) shared_nav_model.load_state_dict(checkpoint['state']) # Load answering model print('Loading answering checkpoint from %s' % args.ans_checkpoint_path) ans_checkpoint = torch.load(args.ans_checkpoint_path, map_location={'cuda:0': 'cpu'}) ans_model_kwargs = {'vocab': load_vocab(args.vocab_json)} shared_ans_model = VqaLstmCnnAttentionModel(**ans_model_kwargs) shared_ans_model.share_memory() print('Loading params from checkpoint: %s' % args.ans_checkpoint_path) shared_ans_model.load_state_dict(ans_checkpoint['state']) if args.mode == 'eval': eval(0, args, shared_nav_model, shared_ans_model) elif args.mode == 'train': train(0, args, shared_nav_model, shared_ans_model) else: processes = []
print('Loading navigation params from checkpoint: %s' % args.nav_checkpoint_path) shared_nav_model.load_state_dict(checkpoint['state']) # Load answering model print('Loading answering checkpoint from %s' % args.ans_checkpoint_path) ans_checkpoint = torch.load( args.ans_checkpoint_path, map_location={ 'cuda:0': 'cpu' }) ans_model_kwargs = {'vocab': load_vocab(args.vocab_json)} shared_ans_model = VqaLstmCnnAttentionModel(**ans_model_kwargs) shared_ans_model.share_memory() print('Loading params from checkpoint: %s' % args.ans_checkpoint_path) shared_ans_model.load_state_dict(ans_checkpoint['state']) if args.mode == 'eval': eval(0, args, shared_nav_model, shared_ans_model) elif args.mode == 'train': train(0, args, shared_nav_model, shared_ans_model) else: processes = []