10/32
Part 3 of 6 · The loss and its gradientLearn and do

Subtract 1 at each row's label, and nowhere else

In code, the one-hot is one line of indexing, and it's easy to get wrong.

grid = np.zeros((3, 3))
labels = np.array([2, 0, 2])
grid[np.arange(3), labels] -= 1
print(grid)
Predict

grid[np.arange(3), labels] -= 1 with labels = [2, 0, 2]. Where do the -1s land?

Pick one to see what it prints.
Pick an answer above to see the rest