Created
March 19, 2019 23:11
-
-
Save icoxfog417/598e56b985babf8a373f5c335d940796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update(self, states, actions, rewards): | |
values = self.critic(states) | |
advantage = reward - tf.stop_gradient(values) # Prevent gradient flows to critic | |
action_probs = self.actor(states) | |
selected_action_probs = action_probs[self.to_one_hot(actions)] | |
neg_logs = - log(selected_action_probs) | |
policy_loss = reduce_mean(neg_logs * advantages) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment