All problems
Entropy Bonus Term In Loss
Problem
Combine a policy-gradient term with an entropy bonus.
Return -mean(log_probs[i] * advantages[i]) - coef * mean(entropies). An empty batch returns 0.0.
Hint
The entropy bonus is subtracted so it rewards keeping the policy stochastic.
Test cases
case 1
in: [[-1,-1],[1,1],[0.5,0.5],0.1]
expected: 0.95
case 2
in: [[-2],[1],[1],0]
expected: 2
case 3
in: [[],[],[],0.1]
expected: 0
Starter codePython
def entropy_regularized_loss(log_probs, advantages, entropies, coef):
# Your code here
pass3 test cases · run your code against them in the editor