I just would like to know if the ndarray has some logic operations, such as ‘and(&)’, ‘or(|)’ etc.

I did not find any in the document.

Thanks

I just would like to know if the ndarray has some logic operations, such as ‘and(&)’, ‘or(|)’ etc.

I did not find any in the document.

Thanks

There is no logical operator in MXNet. However typically anything you’d like to achieve with logical operators can be achieved with existing operators such as `nd.where()`

. If you explain the problem you’re trying to solve using logical operators, I may be able to point you int he right direction.

I would like to compute the true positive for a given class in a multi-class category task.

Assume that gt_label stands for the ground truth label of all examples; pred_label stands for the predicted label. Then, for class c, the TP© can be computed as:

TP© = (gt_label == c & pred_label == c).sum()

Now, I compute it like this:

TP© = ((gt_label == c) * (pred_label == c)).sum()

But, I don’t think it is elegant.

I’d say your solution is pretty elegant I can’t think of a better way.

1 Like