Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-295

Adversarial Domain Loss

Problem

Compute the binary cross-entropy of a domain classifier.

Apply the sigmoid to each logit with probability clamped to [1e-12, 1 - 1e-12], then average -(y * log(p) + (1 - y) * log(1 - p)) over the samples. Round to 4 decimal places.

Test cases

case 1
in: [[0,1],[0,1]]
expected: 0.5032
case 2
in: [[0,0],[0,0]]
expected: 0.6931
case 3
in: [[2,-2],[1,0]]
expected: 0.1269
Starter codePython
def domain_loss(logits, labels):
    # Your code here
    pass

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