Premium problem63. Confusion Matrix

Medium Locked

Build the num_classes x num_classes confusion matrix for true/predicted class labels y_true/y_pred (row = true class, column = predicted class).

Input

y_true = tensor([0, 1, 2, 1, 0, 2])
y_pred = tensor([0, 1, 1, 1, 0, 2])
num_classes = 3

Output

tensor([[2, 0, 0],
        [0, 2, 0],
        [0, 1, 1]])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)