Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

policy_old完全看不出作用 #65

Open
haduoken opened this issue Jan 25, 2024 · 6 comments
Open

policy_old完全看不出作用 #65

haduoken opened this issue Jan 25, 2024 · 6 comments

Comments

@haduoken
Copy link

现在的数据流程是

  1. policy_old = policy
  2. 使用policy_old去交互,生成数据
  3. 使用数据去更新policy模型
  4. policy_old = policy

在这个流程中,policy_old完全没有作用,或者说代码中去掉policy_old,使用policy进行替代,最终的结果完全一致

所以这个真的是PPO么??

@haduoken
Copy link
Author

你这个流程完全等同于

  1. policy 生成数据
  2. policy 迭代更新
  3. loop

@slDeng1003
Copy link

You are right, but the author is also right to do so.

I think the current process is not redundant:

  1. Update the policy K(=80) times per epoch. If the KL divergence needs to be calculated inside the epoch, policy_old must be retained.
  2. In fact, KL divergence can be used as a trick for PPO algorithm. The torch version PPO, implemented by OpenAI Spinning Up, early stops the epoch just when the KL divergence is too large.

@haduoken
Copy link
Author

感谢回复,你的观点我认同,old Policy确实可以用于计算KL散度,让模型本次更新不至于过大

另外当我知道PPO绕了一大圈,最后跟我说另外个分布就是上次的分布时,我是真的想掀桌子

整个PPO完全就是工程化的时候,看到for循环迭代缺少个阻尼项,而做的尝试。实际写出的论文却如此晦涩

@slDeng1003
Copy link

slDeng1003 commented Mar 12, 2024

Although the motivation of PPO might not be that simple, I guess partial of PPO's motivation were found when applying TRPO in engineering.

Actually, introducing KL divergence into PPO to early stop is just a trick. The authors of PPO paper not meant to do that.

In my opinion, PPO is motivated to solve TRPO's computational complexity problem. Instead of computing KL divergence (very slow) like TRPO, PPO(clip version) simply limit the policy's update with a clip() function.

You can check it deeper by viewing OpenAI Spinning Up for PPO, which I have cited it as an url below:)

PPO is motivated by the same question as TRPO: how can we take the biggest possible improvement step on a policy using the data we currently have, without stepping so far that we accidentally cause performance collapse? Where TRPO tries to solve this problem with a complex second-order method, PPO is a family of first-order methods that use a few other tricks to keep new policies close to old. PPO methods are significantly simpler to implement, and empirically seem to perform at least as well as TRPO.

There are two primary variants of PPO: PPO-Penalty and PPO-Clip.

PPO-Penalty approximately solves a KL-constrained update like TRPO, but penalizes the KL-divergence in the objective function instead of making it a hard constraint, and automatically adjusts the penalty coefficient over the course of training so that it’s scaled appropriately.

PPO-Clip doesn’t have a KL-divergence term in the objective and doesn’t have a constraint at all. Instead relies on specialized clipping in the objective function to remove incentives for the new policy to get far from the old policy.

——from OpenAI Spinning Up for PPO

@haduoken
Copy link
Author

嗯,是的。如果从TRPO出发,PPO的改进是成功的

再次感谢你的回答,我后续会看下OpenAI的版本

@slDeng1003
Copy link

You are welcomed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants