Skip to content
DeepForgeby svx
All problems

MARWIL Weighted BC

Problem

Compute the MARWIL weighted behavioral cloning loss.

The weight of each sample is exp(beta * advantage), and the loss is the negative weighted mean of the log-probabilities. A zero total weight or empty batch returns 0.0.

Hint

Beta controls how strongly the advantage tilts the imitation weights.

Test cases

case 1
in: [[-0.5,-1],[0,0],1]
expected: 0.75
case 2
in: [[-0.5,-1],[1,-1],1]
expected: 0.5596014610110588
case 3
in: [[],[],1]
expected: 0
Starter codePython
import math
def marwil_weighted_loss(log_probs, advantages, beta):
    # Your code here
    pass

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