Example
Example of Indexing Predicted Probabilities
Consider a batch containing examples where a model outputs predicted probabilities over classes, represented by the matrix . If the true class labels for these examples are and respectively, the label vector is . Using array indexing, we can efficiently extract the predicted probabilities corresponding to the true labels without writing a for-loop. For the first example (true class ), we select the first element of the first row (). For the second example (true class ), we select the third element of the second row (). The resulting array of selected probabilities is .
0
1
Updated 2026-05-03
Tags
D2L
Dive into Deep Learning @ D2L