hysts/pytorch_image_classification

How could I change the code?

Chen65010445 opened this issue · 3 comments

image

When I trying to use self-changed evaluate.py to evaluate my own dataset this error always came first. Do you know how could I change the code? I already add this :
transforms.ToTensor()in evaluate.py and changed the code in dataset.py as return self.transform(self.x[index]), self.transform(self.y[index])
Is there any other way to eliminate the error?

hysts commented

Hi, @Chen65010445

Ah, sorry about that. Currently, the code only works with CIFAR and MNIST.
I think the test_loader in this code is a tuple of train_loader and val_loader in your case because of this code.
So I think you can change that part of the code appropriately to make it work.

But I can finish the training with my own dataset in this code. So is there anything wrong I couldn't finish the prediction? Or is there any sepcific code to run the prediction?

hysts commented

@Chen65010445

Oh, sorry, I didn't notice your comment.

The reason you could train your model with your own dataset without errors is because the training code only uses a training dataset and a validation dataset and it doesn't need a test dataset.

Although you need a test dataset to run evaluate.py, this code doesn't have the functionality to return test_dataset. And the reason it doesn't is because the ImageNet dataset doesn't have test labels. So, for your dataset, you need to modify the code to return your test dataset.