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

get action in sac_continuous_action.py #428

Open
2 of 3 tasks
zichunxx opened this issue Nov 10, 2023 · 2 comments
Open
2 of 3 tasks

get action in sac_continuous_action.py #428

zichunxx opened this issue Nov 10, 2023 · 2 comments

Comments

@zichunxx
Copy link

zichunxx commented Nov 10, 2023

Problem Description

Hi! Thanks for this clean script to help me understand sac.

But I have some questions about the implementation of sac's get action function, mainly focused on the following code snippet

# Enforcing Action Bound
log_prob -= torch.log(self.action_scale * (1 - y_t.pow(2)) + 1e-6)
log_prob = log_prob.sum(1, keepdim=True)

What is the purpose of this? Thanks!

Checklist

@Howuhh
Copy link
Contributor

Howuhh commented Nov 10, 2023

Usually in SAC we use Normal distribution coupled with tanh to bound action space. However, after such transformation the actual distribution is now not just standard Normal and we can not use it's lob_prob to get the probabilities of actions. This formula accounts for the transformation and gives right probabilities for TanhNormal distribution. See Appendix C in the original paper: https://arxiv.org/pdf/1801.01290.pdf

@zichunxx
Copy link
Author

Thanks for your generous help @Howuhh. Is 1e-6 meant to limit the logarithmic value to approach negative infinity?

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