12/32
Part 3 of 6 · The loss and its gradientLearn and do
A loss that survives huge logits
Subtract each row's max, and np.exp can't overflow
The practice tests push the logits into the tens of thousands, and np.exp has a limit.
print(np.exp(709.0), np.exp(710.0))
row = np.array([30000.0, 30002.0, 29999.0])
print(np.exp(row - row.max()))
What do np.exp(709.0) and np.exp(710.0) print in float64?
Pick one to see what it prints.
Pick an answer above to see the rest