Welcome to our Support Center

OneHotIoU

Description

Computes the Intersection-Over-Union metric for one-hot encoded labels. Type : polymorphic.

 

 

Input parameters

 

 y_pred : array, predicted values.
 y_true : array, true values (one hot encoding for example, [0, 0, 1] for 3-class problem).

parameters : cluster,

 target_class_ids : array, list of target class ids for which the metric is returned.
sparse_y_pred : boolean, whether predictions are encoded using integers or one hot logits. If True predictions are integers and if False, predictions are one hot logits and the argmax function will be used to determine each sample’s most likely associated label according to “axis” parameters.
 axis : integer, the dimension containing the logits.

Output parameters

 

one_hot_iou : float, result.

Calculation

This metric can be used to compute IoU for multi-class classification tasks where the labels are one-hot encoded (the last axis should have one dimension per class). If the boolean parameter sparse_y_pred is set to true, this means that the predictions are not encoded in one-hot, but are sparse integers. Consequently, it is not necessary to convert them to integer format using argmax on the class axis. Otherwise, if sparse_y_pred is false, then the labels and predictions are first converted to integer format using argmax on the class axis before the IoU is calculated.

So, depending on the value of sparse_y_pred, OneHotIoU can accommodate both one-hot encoded predictions and sparse integer predictions.

Note that if there is only one channel in the labels and predictions, this class is identical to the IoU class. In this case, use IoU instead.

 

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install HAIBAL library to run it).

Easy to use with one_hot

Easy to use with sparse

Table of Contents