how and where can i set index for class?
You can set the class index manually, if you are creating the dataset.
If you are using a dataset from
torchvision, such as
MNIST, the classes would be already predefined.
ImageFolder, the specified folders will be sorted and the class indices will be created according to the sorted folders starting at 0.
What sorting order is followed? if there is cat and dog folder , which one is index:0
The order is determined by the
sort() method used in this line of code, which might be OS-dependent. In your example,
cat would most likely be class0 and
dog class1 and you can check it via the
However, there were differences on Windows and Linux in the sorting of names starting with numbers.
If I remember correctly, you would have to prepend zeros to the name to get the same sorting:
00001 00002 00003 ... 00010 00011