update codes
This commit is contained in:
@@ -72,7 +72,7 @@ def train(cfg,env,agent):
|
||||
else:
|
||||
action = (
|
||||
agent.choose_action(np.array(state))
|
||||
+ np.random.normal(0, max_action * cfg.expl_noise, size=action_dim)
|
||||
+ np.random.normal(0, max_action * cfg.expl_noise, size=n_actions)
|
||||
).clip(-max_action, max_action)
|
||||
# Perform action
|
||||
next_state, reward, done, _ = env.step(action)
|
||||
@@ -121,11 +121,11 @@ def train(cfg,env,agent):
|
||||
# else:
|
||||
# action = (
|
||||
# agent.choose_action(np.array(state))
|
||||
# + np.random.normal(0, max_action * cfg.expl_noise, size=action_dim)
|
||||
# + np.random.normal(0, max_action * cfg.expl_noise, size=n_actions)
|
||||
# ).clip(-max_action, max_action)
|
||||
# # action = (
|
||||
# # agent.choose_action(np.array(state))
|
||||
# # + np.random.normal(0, max_action * cfg.expl_noise, size=action_dim)
|
||||
# # + np.random.normal(0, max_action * cfg.expl_noise, size=n_actions)
|
||||
# # ).clip(-max_action, max_action)
|
||||
# # Perform action
|
||||
# next_state, reward, done, _ = env.step(action)
|
||||
@@ -157,10 +157,10 @@ if __name__ == "__main__":
|
||||
env.seed(cfg.seed) # Set seeds
|
||||
torch.manual_seed(cfg.seed)
|
||||
np.random.seed(cfg.seed)
|
||||
state_dim = env.observation_space.shape[0]
|
||||
action_dim = env.action_space.shape[0]
|
||||
n_states = env.observation_space.shape[0]
|
||||
n_actions = env.action_space.shape[0]
|
||||
max_action = float(env.action_space.high[0])
|
||||
agent = TD3(state_dim,action_dim,max_action,cfg)
|
||||
agent = TD3(n_states,n_actions,max_action,cfg)
|
||||
rewards,ma_rewards = train(cfg,env,agent)
|
||||
make_dir(cfg.result_path,cfg.model_path)
|
||||
agent.save(path=cfg.model_path)
|
||||
|
||||
Reference in New Issue
Block a user