All problems
Overfitting Gap
Problem
Return the gap between validation and training loss at the best epoch, i.e. the epoch with the lowest validation loss (ties go to the earliest).
Empty input returns 0.0.
Hint
Evaluate the generalization gap at the best validation epoch, not at the last epoch.
Test cases
case 1
in: [[0.5,0.4,0.3],[0.6,0.5,0.55]]
expected: 0.09999999999999998
case 2
in: [[0.9,0.7],[0.95,0.6]]
expected: -0.09999999999999998
case 3
in: [[0.2],[0.3]]
expected: 0.09999999999999998
case 4
in: [[],[]]
expected: 0
Starter codePython
def overfitting_gap(train_losses, val_losses):
# Your code here
pass4 test cases · run your code against them in the editor