mmcls.core.calculate_confusion_matrix¶
- mmcls.core.calculate_confusion_matrix(pred, target)[source]¶
Calculate confusion matrix according to the prediction and target.
- Parameters
pred (torch.Tensor | np.array) – The model prediction with shape (N, C).
target (torch.Tensor | np.array) – The target of each prediction with shape (N, 1) or (N,).
- Returns
- Confusion matrix
The shape is (C, C), where C is the number of classes.
- Return type