Where are you using num_classes in the code further?
It depends, how the target is created. If you use ImageFolder, the target will be automatically created using all subfolders from the root you provided. However, you could easily define the target yourself.
I’m currently not sure, what kind of code you are using.