Deep Learning, Machine Learning, Artificial Intelligence, Loss Function, Neural Networks.
tensor y_true = torch.tensor([1, 2, 0]) y_pred = torch.tensor([[0.1, 0.8, 0.1], [0.3, 0.2, 0.5], [0.4, 0.3, 0.3]]) # calculate the loss loss = sparse_categorical_crossentropy(y_true, y_pred) # print the loss print(loss.item()) In this implementation, y_true is an array of integer labels and y_pred