@ptrblck: thank you for your reply but I am not sure I understand what you have said
So, dataset.classes does return folder names, but when I loop through ds , the target is showing me indices of dataset.classes rather than the folder name
To the NN I would pass the sample and the target(which here is the folder name), not the indices, right?
I am confused as to why this is… I obviously do not understand something
So, when I do:
for idx, (sample, target) in enumerate(train_dataset):
print(sample, list_of_classes[target] )
it seems to pick up the correct labels(aka target/folder_names). Is this the correct way to do it?
That is expected and the target should contain the class indices, not the names.
So e.g. for three folders your target should contain values in [0, 1, 2]
These target values are used to index the output of the model during the loss calculation, so they are used as numerical values instead of the folder names.
@ptrblck: thank you for this clarification. I think I got confused because my folder_names were also integers. It does make sense, since we compute the probability of classes at the end and thus indexing makes sense.