I'm trying to solve LunarLanderContinuous-v2 (https://www.gymlibrary.ml/environments/box2d/lunar_lander/) using Soft Actor-Critic algorithm (following the pseudocode above)
To update the actor policy (step 14) I understood that I need to:
- sample an action from a normal distribution using mean and variance that are the output of the policy network
- squash the action with tanh to have action bounds [-1, 1]
- compute the log_prob, the log probability density of the sample
- do the following operation in tensorflow
# STEP 14
bounded_actions_sample, predicted_next_actions_sample = policy_network.predict_actions(batch_observation)
pdf = get_pdf(predicted_next_actions_sample, batch_observation)
q_min = tf.math.minimum(q_network_1(batch_observation, bounded_actions_sample), q_network_2(batch_observation, bounded_actions_sample))
loss_policy_network = tf.reduce_mean(alfa * tf.math.log(pdf) - q_min))
where "pdf" is the value of the probability density function of the normal distribution computed from predicted action (not clipped), mean and variance.
Since the action space of LunarLanderContinuous-v2 is continuous and the possible actions are 2, my idea is to predict means μ, variances σ and a correlation ρ parameter in order to build a Multivariate normal distribution using tfp.distributions.MultivariateNormalTriL and sample actions from it.
My problem is that, according to the Appendix C of the paper https://arxiv.org/pdf/1801.01290.pdf, I have to compute the likelihoods of the bounded actions using
but I don't know how to do that because the first term is a single number due to it come from a Multivariate normal distribution, instead the second term contains 2 elements, one for each action. Has anyone any idea to code it?