Accuracy
Classification accuracy metric.
Computes the fraction of predictions that match the target labels. Supports both hard targets (class indices) and soft targets (one-hot or probabilities).
For predictions, the class with maximum value along dim is selected. For soft targets, the class with maximum value is used as the ground truth. For hard targets (Int32), the value directly represents the class index.
Parameters
dim
The dimension along which to find the predicted class (default: -1, last dimension)
threshold
Optional threshold for binary classification. If provided, predictions > threshold are classified as class 1, otherwise class 0. Only applicable when dim size is 1 or 2.