Construct binary label vector given a list of label indices. Args: labels (list): The input label list. num_classes (int): Number of classes of the label vector. Returns: labels (numpy array): the resulting binary vector.
(labels, num_classes)
| 257 | |
| 258 | |
| 259 | def as_binary_vector(labels, num_classes): |
| 260 | """ |
| 261 | Construct binary label vector given a list of label indices. |
| 262 | Args: |
| 263 | labels (list): The input label list. |
| 264 | num_classes (int): Number of classes of the label vector. |
| 265 | Returns: |
| 266 | labels (numpy array): the resulting binary vector. |
| 267 | """ |
| 268 | label_arr = np.zeros((num_classes,)) |
| 269 | |
| 270 | for lbl in set(labels): |
| 271 | label_arr[lbl] = 1.0 |
| 272 | return label_arr |
| 273 | |
| 274 | |
| 275 | def aggregate_labels(label_list): |
nothing calls this directly
no outgoing calls
no test coverage detected