Skip to content

Commit e029640

Browse files
committed
More cleanup of nonused files etc.
1 parent 720beda commit e029640

File tree

8 files changed

+6
-600
lines changed

8 files changed

+6
-600
lines changed

envs/sorting_task.py

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,6 @@ def reward_nco(sample_solution, use_KT, use_cuda=False):
4343
else:
4444
return -reward_ddpg_C(solutions.permute(1, 2, 0), use_cuda, True)
4545

46-
def reward_gcn(solution, use_cuda):
47-
"""
48-
solution is FloatTensor of dim [1,n]
49-
"""
50-
sourceL = solution.size()[1]
51-
52-
longest = Variable(torch.ones(1), requires_grad=False)
53-
current = Variable(torch.ones(1), requires_grad=False)
54-
random_baseline = Variable(torch.FloatTensor([0.3]))
55-
if use_cuda:
56-
longest = longest.cuda()
57-
current = current.cuda()
58-
random_baseline = random_baseline.cuda()
59-
for i in range(1, sourceL):
60-
res = torch.lt(solution[0, i-1], solution[0, i])
61-
current += res.float()
62-
current[torch.eq(res, 0)] = 1
63-
mask = torch.gt(current, longest)
64-
longest[mask] = current[mask]
65-
66-
return torch.div(longest, sourceL)
67-
6846
def reward_ddpg_A(solution, use_cuda):
6947
"""
7048
Count number of consecutively correctly sorted for each sample in minibatch
@@ -143,6 +121,9 @@ def reward_ddpg_C(solution, use_cuda, nco=False):
143121
return torch.div(longest, m)
144122

145123
def reward_ddpg_D(solution, use_cuda):
124+
"""
125+
Kendall-Tau correlation coefficient
126+
"""
146127
(batch_size, n, m) = solution.size()
147128
if use_cuda:
148129
solution = solution.data.cpu().numpy()
@@ -279,42 +260,3 @@ def __len__(self):
279260

280261
def __getitem__(self, idx):
281262
return self.data_set[idx]
282-
283-
if __name__ == '__main__':
284-
if int(sys.argv[1]) == 0:
285-
sample = Variable(torch.Tensor([[3, 2, 1, 4, 5]]))
286-
#sample = [Variable(torch.Tensor([3,2])), Variable(torch.Tensor([2,3])), Variable(torch.Tensor([1,5])),
287-
# Variable(torch.Tensor([4, 1])), Variable(torch.Tensor([5, 4]))]
288-
answer = torch.Tensor([3/5.])
289-
290-
res = reward_no_batch(sample, False)
291-
292-
print('Expected answer: {}, Actual answer: {}'.format(answer, res.data))
293-
"""
294-
sample = Variable(torch.Tensor([[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]))
295-
answer = torch.Tensor([1., 1/5])
296-
297-
res = reward(sample)
298-
299-
print('Expected answer: {}, Actual answer: {}'.format(answer, res.data))
300-
301-
sample = Variable(torch.Tensor([[1, 2, 5, 4, 3], [4, 1, 2, 3, 5]]))
302-
answer = torch.Tensor([3/5., 4/5])
303-
304-
res = reward(sample)
305-
306-
print('Expected answer: {}, Actual answer: {}'.format(answer, res.data))
307-
"""
308-
elif int(sys.argv[1]) == 1:
309-
data_dir = '/home/pemami/Workspace/deep-assign/data/sort/icml2018'
310-
N = [10, 15, 20, 25]
311-
for n in N:
312-
create_dataset(500000, 10000, data_dir, 666, 0, n-1, True, 3)
313-
314-
elif int(sys.argv[1]) == 2:
315-
316-
sorting_data = SortingDataset('data', 'sorting-size-1000-len-10-train.txt',
317-
'sorting-size-100-len-10-val.txt')
318-
for i in range(len(sorting_data)):
319-
print(sorting_data[i])
320-

envs/tsp_task.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,3 @@ def __len__(self):
315315

316316
def __getitem__(self, idx):
317317
return self.data_set[idx]
318-
319-
if __name__ == '__main__':
320-
#paths = download_google_drive_file('data/tsp', 'tsp', '', '50')
321-
data_dir='/home/pemami/Workspace/deep-assign/data/tsp/icml2018/'
322-
create_dataset(500000, 1000, data_dir, 15, 0, False, 10)
323-
create_dataset(500000, 1000, data_dir, 20, 0, False, 10)
324-
create_dataset(500000, 1000, data_dir, 25, 0, False, 10)

neural_combinatorial_rl/plot_attention.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

neural_combinatorial_rl/tsp_task.py

Lines changed: 0 additions & 248 deletions
This file was deleted.

run_nco.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
22

33
INPUT_SIZE=20
4-
TASK="sort_0-19"
5-
N_FEATURES=1
4+
TASK="tsp_20"
5+
N_FEATURES=2
66
USE_DECODER='True'
77
TRAIN_SIZE=500000
88
VAL_SIZE=1000
99
EMBEDDING_DIM=128
1010
HIDDEN_DIM=128
1111
PARALLEL_ENVS=128
1212
BATCH_SIZE=128
13-
ACTOR_NET_LR=1e-4
13+
ACTOR_NET_LR=1e-3
1414
ACTOR_LR_DECAY_RATE=0.96
1515
ACTOR_LR_DECAY_STEP=5000
1616
N_GLIMPSES=1

0 commit comments

Comments
 (0)