Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-354

Loss Plateau Detection

Problem

A training loss has plateaued when the latest value is within tol of the mean of the preceding values.

Given the loss history (at least two entries) and tol, return True when abs(last - mean(previous)) < tol.

Hint

Exclude the latest value from the reference mean.

Test cases

case 1
in: [[1,1,1.0001],0.001]
expected: true
case 2
in: [[1,2,5],0.001]
expected: false
case 3
in: [[2,2],0]
expected: false
Starter codePython
def loss_plateau_detection(losses, tol):
    # Your code here
    pass

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