Beispiel #1
0
 def _transform(self, input: Any, params: Dict[str, Any]) -> Any:
     if type(input) is features.Label:
         num_categories = self.num_categories
         if num_categories == -1 and input.categories is not None:
             num_categories = len(input.categories)
         output = F.label_to_one_hot(input, num_categories=num_categories)
         return features.OneHotLabel(output, categories=input.categories)
     else:
         return input
def make_one_hot_label(*args, **kwargs):
    label = make_label(*args, **kwargs)
    return features.OneHotLabel(one_hot(label,
                                        num_classes=len(label.categories)),
                                categories=label.categories)