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

A question about rl training function #49

Open
ZefanW opened this issue May 5, 2019 · 2 comments
Open

A question about rl training function #49

ZefanW opened this issue May 5, 2019 · 2 comments

Comments

@ZefanW
Copy link

ZefanW commented May 5, 2019

for action, p, r, b in zip(indices, probs, reward, baseline): advantage = r - b avg_advantage += advantage losses.append(-p.log_prob(action) * (advantage/len(indices))) # divide by T*B

I have a question about this piece of code.
If I didn't get it wrong, the variable b here is tensor with gradient enabled, so optimizing tensors in losses will actually both optimize reward by changing policy weights and minimizing the advantage by maximizing baseline. I can't understand why the baseline is optimized here, because as far as I know, the baseline should only be optimized during the training of the critic.
Actually I used this training function in a different summarization task, and I found that the avg_advantage is always dropping.
Thank you very much.

@ZefanW
Copy link
Author

ZefanW commented May 5, 2019

I changed r-b to (r-b).item(), and it seems alright.

@ChenRocks
Copy link
Owner

Thanks for pointing this out! I think your solution should work as intended. I will test how this affect the results when I have time.

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