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 in DDPG.train_on_batch #2

Open
lbgitjp opened this issue Oct 25, 2022 · 0 comments
Open

a question in DDPG.train_on_batch #2

lbgitjp opened this issue Oct 25, 2022 · 0 comments

Comments

@lbgitjp
Copy link

lbgitjp commented Oct 25, 2022

I think below code maybe has problem:

# train actor-critic by target loss
self.actor_network.train(
self.critic_network.train(
y_batch, action_batch, state_batch
)
)

The two gradients need to be calculated separately, because their loss functions are different.
I think it should be changed to below:

`

    #for critic
    self.critic_network.train(y_batch, action_batch, state_batch)

    #for actor
    actor_loss =-self.critic_network.critic(self.actor_network.actor_action(state_batch), state_batch).mean()
    self.actor_network.optimizer.zero_grad()
    actor_loss.backward()
    self.actor_network.optimizer.step()

`
thanks!

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

1 participant