Fix inconsistent seeding & clean up code

This commit is contained in:
pranz24
2020-07-11 14:15:04 +05:30
parent ec004304a9
commit 1bd1158116
3 changed files with 8 additions and 3 deletions
+2
View File
@@ -0,0 +1,2 @@
__pycache__/
runs/
+4 -2
View File
@@ -49,9 +49,11 @@ args = parser.parse_args()
# Environment
# env = NormalizedActions(gym.make(args.env_name))
env = gym.make(args.env_name)
env.seed(args.seed)
env.action_space.seed(args.seed)
torch.manual_seed(args.seed)
np.random.seed(args.seed)
env.seed(args.seed)
# Agent
agent = SAC(env.observation_space.shape[0], env.action_space, args)
@@ -61,7 +63,7 @@ writer = SummaryWriter('runs/{}_SAC_{}_{}_{}'.format(datetime.datetime.now().str
args.policy, "autotune" if args.automatic_entropy_tuning else ""))
# Memory
memory = ReplayMemory(args.replay_size)
memory = ReplayMemory(args.replay_size, args.seed)
# Training Loop
total_numsteps = 0
+2 -1
View File
@@ -2,7 +2,8 @@ import random
import numpy as np
class ReplayMemory:
def __init__(self, capacity):
def __init__(self, capacity, seed):
random.seed(seed)
self.capacity = capacity
self.buffer = []
self.position = 0