Category list to one-hot encoding

Hi,
I have a dataset in Imagenet format where the images are stored in folders based on the category name. I want to build a multiclass classifier so that I can use Sigmoid loss function instead of Softmax for the purpose of being able to detect missing classes.
So I load the data using:
data=ImageList.from_folder(path=path).split_by_rand_pct(valid_pct=0.2).label_from_folder()
But I would like to have my labels as one hot encoded MultiCategoryList and what I get is a CategoryList which I can’t use with torch.nn.BCEWithLogitsLoss.
How can I easily make this transformation?
Thanks!

Assuming your folder names don’t have multiple labels you need to extract, passing MultiCategoryList to the label_cls parameter of label_from_folder should do the trick.

Otherwise you will probably need to use label_from_func or label_from_re to extract the labels from the folder names. label_from_folder calls label_from_func so you can look at it as an example if needed.