Skip to content
DeepForgeby svx
All problems

Temperature-Scaled Policy Log-Probs

Problem

Return the full vector of log-probabilities for a policy after temperature scaling.

Compute log_softmax(logits / temperature) using the max-subtraction trick. Temperature is positive.

Hint

PPO needs log-probabilities, so returning log-softmax avoids an extra log of a probability.

Test cases

case 1
in: [[0,0],1]
expected: [-0.6931471805599453,-0.6931471805599453]
case 2
in: [[0,1],1]
expected: [-1.3132616875182228,-0.3132616875182228]
case 3
in: [[0,1],0.5]
expected: [-2.1269280110429727,-0.1269280110429727]
Starter codePython
import math
def temperature_log_probs(logits, temperature):
    # Your code here
    pass

3 test cases · run your code against them in the editor