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

who do struggle with tf.nn.softmax_cross_entropy_with_logits_v2 in Cartpole REINFORCE Monte Carlo Policy Gradients #85

Open
gekator opened this issue Dec 8, 2022 · 0 comments

Comments

@gekator
Copy link

gekator commented Dec 8, 2022

Guys, if you struggle with
neg_log_prob = tf.nn.softmax_cross_entropy_with_logits_v2(logits = fc3, labels = actions)
in n Cartpole REINFORCE Monte Carlo Policy Gradients.
I killed some time to understand what is happening there
You can change code as bellow:

y_hat_softmax = tf.nn.softmax(fc3)

y_cross = actions * tf.log(y_hat_softmax)

neg_log_prob = - tf.reduce_sum(y_cross, 1)

loss = tf.reduce_mean(neg_log_prob * discounted_episode_rewards_)

also change
actions = tf.placeholder(tf.float32, [None, action_size], name="actions")

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