mirror of
https://github.com/wassname/pytorch-soft-actor-critic.git
synced 2026-06-27 16:46:28 +08:00
Fix inconsistent seeding & clean up code
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
__pycache__/
|
||||
runs/
|
||||
@@ -46,9 +46,11 @@ args = parser.parse_args()
|
||||
|
||||
# Environment
|
||||
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)
|
||||
@@ -56,7 +58,7 @@ agent = SAC(env.observation_space.shape[0], env.action_space, args)
|
||||
writer = SummaryWriter('runs/{}_SAC_V_{}'.format(datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S"), args.env_name))
|
||||
|
||||
# Memory
|
||||
memory = ReplayMemory(args.replay_size)
|
||||
memory = ReplayMemory(args.replay_size, args.seed)
|
||||
|
||||
# Training Loop
|
||||
total_numsteps = 0
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user