forked from JPedroRBelo/pyMDQN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_epoch.py
67 lines (41 loc) · 1.29 KB
/
delete_epoch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import torch
import numpy as np
import pickle
import sys
datContent = []
def remove(row):
folder = 'files'
rewards=torch.load(folder+'/reward_history.dat')#.detach().cpu().numpy()
actions=torch.load(folder+'/action_history.dat')#.detach().cpu().numpy()
recent_rewards=torch.load('recent_rewards.dat')#.detach().cpu().numpy()
recent_actions=torch.load('recent_actions.dat')#.detach().cpu().numpy()
ep_rewards=torch.load(folder+'/ep_rewards.dat')
#torch.save(rewards[row],folder+'/bkup_rewards.dat'+str(row))
#torch.save(actions[row],folder+'/bkup_actions.dat'+str(row))
print(len(rewards))
print(len(actions))
print(len(ep_rewards))
rewards = list(rewards)
actions = list(actions)
#rewards.append(recent_rewards)
#actions.append(recent_actions)
while(len(rewards)>14):
rewards.pop(-1)
actions.pop(-1)
ep_rewards.pop(-1)
print(len(rewards))
print(len(actions))
print(len(ep_rewards))
#new_actions = np.delete(actions, row, 0)
#total_reward = 0
#for i in recent_rewards:
# total_reward += i
#ep_rewards.append(total_reward)
#
#torch.save(ep_rewards,folder+'/ep_rewards.dat')
#torch.save(rewards,folder+'/reward_history.dat')
#torch.save(actions,folder+'/action_history.dat')
if len(sys.argv) > 1:
row = int(sys.argv[1])
#print('Removing row: ',row)
remove(row)