Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-128

Loss Spike Detection

Problem

Flag loss spikes using a z-score over the whole loss list: return the indices where (loss - mean) / std exceeds z_threshold, using the population standard deviation. If the standard deviation is zero, return an empty list.

The signature is loss_spike_detect(losses, z_threshold).

Hint

A spike is an outlier relative to the training run's own loss distribution.

Test cases

case 1
in: [[1,1.1,0.9,1,5],1.5]
expected: [4]
case 2
in: [[1,1,1],2]
expected: []
case 3
in: [[10,1,1,1],1]
expected: [0]
case 4
in: [[0.5,0.6,0.55,2],1]
expected: [3]
Starter codePython
import math
def loss_spike_detect(losses, z_threshold):
    # Your code here
    pass

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