REINFORCE Gradient for a Softmax Policy
~14 mincode completion
Implement reinforce_grad(logits, action, ret) returning the gradient of with respect to the logits, as an array the same length as logits.
Python
import numpy as np
def reinforce_grad(logits, action, ret):
"""
Gradient of ret * log softmax(logits)[action] with respect to the logits.
Args:
logits: (A,) unnormalized action scores
action: index of the action taken
ret: return G that followed the action
Returns:
(A,) array, the gradient with respect to each logit
"""
# YOUR CODE HERE
pass