exp_time = "{0:%Y-%m-%d}_{0:%H-%M-%S}".format(datetime.now()) SAVEDIR = os.path.join('./saves', 'copytask', NET_TYPE, str(random_seed), exp_time) torch.cuda.manual_seed(random_seed) torch.manual_seed(random_seed) np.random.seed(random_seed) inp_size = 1 T = args.T batch_size = args.batch out_size = args.labels + 1 if args.onehot: inp_size = args.labels + 2 rnn = select_network(args, inp_size) net = Model(hidden_size, rnn) if CUDA: net = net.cuda() net.rnn = net.rnn.cuda() print('Copy task') print(NET_TYPE) print('Cuda: {}'.format(CUDA)) print(nonlin) print(hidden_size) for name, param in net.named_parameters(): if param.requires_grad: print(name, param.data) if not os.path.exists(SAVEDIR): os.makedirs(SAVEDIR)
val_data = batchify(corpus.valid, eval_batch_size) test_data = batchify(corpus.test, eval_batch_size) ############################################################################### # Build the model ############################################################################### ntokens = len(corpus.dictionary) NET_TYPE = args.net_type inp_size = args.emsize hid_size = args.nhid alam = args.alam CUDA = args.cuda nonlin = args.nonlin rnn = select_network(inp_size, args) model = RNNModel(rnn, ntokens, inp_size, hid_size, args.tied) if args.cuda: model.cuda() print('Language Task') print(NET_TYPE) print(args) criterion = nn.CrossEntropyLoss() ############################################################################### # Training code ###############################################################################
NET_TYPE = args.net_type CUDA = args.cuda decay = args.weight_decay hidden_size = args.nhid torch.cuda.manual_seed(random_seed) torch.manual_seed(random_seed) np.random.seed(random_seed) inp_size = 1 T = args.T batch_size = args.batch out_size = args.labels + 1 if args.onehot: inp_size = args.labels + 2 rnn = select_network(NET_TYPE, inp_size, hidden_size, nonlin, args.rinit, args.iinit, CUDA, args.lastk, args.rsize) net = Model(hidden_size, rnn) net.load_state_dict(torch.load('relcopylogs/' + args.name + '.pt')) net.rnn.T = args.T + 20 net.rnn.cutoff = args.cutoff if CUDA: net = net.cuda() net.rnn = net.rnn.cuda() print('Copy task') print(NET_TYPE) print('Cuda: {}'.format(CUDA)) print(nonlin) print(hidden_size)