-
Notifications
You must be signed in to change notification settings - Fork 342
Closed
Description
Hi,
def accuracy_multilabel(y_pred:Tensor, y_true:Tensor, sigmoid:bool=True):
if sigmoid: y_pred = y_pred.sigmoid()
outputs = np.argmax(y_pred, axis=1)
real_vals = np.argmax(y_true, axis=1)
return np.mean(outputs.numpy() == real_vals.numpy())in this block.
This piece of code seems incorrect as the shape of y_pred and y_true is (Batch_size, class_space).
Doing a np.argmax with axis=1 returns a single class index value for each sample.
This is what we do for multi-class classification.
However in multi-class classification we don't normally use sigmoid on y_pred, although it is not wrong.
This function seems much like accuracy_multiclass rather than accuracy_multilabel
Pawel-Kranzberg
Metadata
Metadata
Assignees
Labels
No labels