Count of correct top-1 predictions as an int64 0-d Tensor.
Equivalent to (logits.argmax(dim=dim) == target).long().sum() —
written as a single function so the four-op chain in user code
collapses to one Python wrap. The complementary primitive to
accuracy: where accuracy divides by total count
eagerly, correct_count keeps the count integer so the user can
accumulate across batches and divide once at the end of the epoch.
Parameters
Returns
Tensor0-d int64 scalar — the number of positions where
argmax(logits) == target.
Examples
>>> import lucid
>>> import lucid.nn.functional as F
>>> logits = lucid.tensor([[2.0, 1.0, 0.0], [0.0, 1.0, 2.0]])
>>> target = lucid.tensor([0, 1])
>>> F.correct_count(logits, target).item()
1