update
This commit is contained in:
@@ -34,7 +34,7 @@ class DDPGConfig:
|
||||
self.env_name = env_name # 环境名称
|
||||
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # 检测GPU
|
||||
self.train_eps = 300 # 训练的回合数
|
||||
self.eval_eps = 50 # 测试的回合数
|
||||
self.test_eps = 50 # 测试的回合数
|
||||
self.gamma = 0.99 # 折扣因子
|
||||
self.critic_lr = 1e-3 # 评论家网络的学习率
|
||||
self.actor_lr = 1e-4 # 演员网络的学习率
|
||||
|
||||
@@ -42,7 +42,7 @@ def test(cfg, env, agent):
|
||||
print(f'环境:{cfg.env_name}, 算法:{cfg.algo}, 设备:{cfg.device}')
|
||||
rewards = [] # 记录所有回合的奖励
|
||||
ma_rewards = [] # 记录所有回合的滑动平均奖励
|
||||
for i_ep in range(cfg.eval_eps):
|
||||
for i_ep in range(cfg.test_eps):
|
||||
state = env.reset()
|
||||
done = False
|
||||
ep_reward = 0
|
||||
@@ -59,6 +59,6 @@ def test(cfg, env, agent):
|
||||
ma_rewards.append(0.9*ma_rewards[-1]+0.1*ep_reward)
|
||||
else:
|
||||
ma_rewards.append(ep_reward)
|
||||
print(f"回合:{i_ep+1}/{cfg.eval_eps},奖励:{ep_reward:.1f}")
|
||||
print(f"回合:{i_ep+1}/{cfg.test_eps},奖励:{ep_reward:.1f}")
|
||||
print('完成测试!')
|
||||
return rewards, ma_rewards
|
||||
Reference in New Issue
Block a user