AI4Finance-Foundation / AI4Finance-Foundation/ElegantRL

One confusion about DQN

未关闭
#404 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
4.4k
派生
978
PR 合并指标
30 天内没有已合并 PR

描述

def valid_agent(env_class, env_args: dict, net_dims: List[int], agent_class, actor_path: str, render_times: int = 8):
env = build_env(env_class, env_args)

state_dim = env_args['state_dim']
action_dim = env_args['action_dim']
agent = agent_class(net_dims, state_dim, action_dim, gpu_id=-1)
actor = agent.act

print(f"| render and load actor from: {actor_path}")
actor.load_state_dict(th.load(actor_path, map_location=lambda storage, loc: storage))
for i in range(render_times):
cumulative_reward, episode_step = get_rewards_and_steps(env, actor, if_render=True)
print(f"|{i:4} cumulative_reward {cumulative_reward:9.3f} episode_step {episode_step:5.0f}")

Does the above code read the trained pth(dict) files, namely neural network parameters, and directly test the new environment with the neural network (no longer use the explore rate)? Why do you choose th.save(actor.state_dict(), save_path) instead of direct actor for saving pth files?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。