Skip to content
DeepForgeby svx
All problems

AWAC Normalized Advantage Weight

Problem

Compute AWAC advantage weights with batch mean normalization.

Subtract the mean advantage before exponentiating: w_i = exp((a_i - mean(a)) / lam). This shifts all weights by a constant factor while keeping their ratios intact. An empty list returns [] and lam is positive.

Hint

Mean subtraction makes the exponent numerically safe without changing relative weights.

Test cases

case 1
in: [[0,1],1]
expected: [0.6065306597126334,1.6487212707001282]
case 2
in: [[1,1],0.5]
expected: [1,1]
case 3
in: [[],1]
expected: []
case 4
in: [[2,0],2]
expected: [1.6487212707001282,0.6065306597126334]
Starter codePython
import math
def awac_normalized_advantage_weight(advantages, lam):
    # Your code here
    pass

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