Given a list of per-layer gradient norms (ordered from input layer to output), return the index of the first layer whose norm is more than threshold times the running maximum of all previous layers (and a baseline of 1.0).
Signature: def find_exploding_layer(grad_norms: list, threshold: float = 100.0) -> int
For index i, the running max baseline is max(grad_norms[:i] + [1.0]). If grad_norms[i] / running_max > threshold, return i. Return -1 if no layer explodes.
Math
Asked at
import numpy as np
def find_exploding_layer(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?