How to use one picture to test the accuracy of my MLP neural network

I use MINST benchmark to training a simple MLP neural network(batch size = 32), but in the test phase, i want to use one picture to test. Does anyone know about it ?

I’m not sure whether it’s what’s you’re asking or not, but I’d say you may be missing the reshaping of your one testing image.

There shouldn’t be any difference between training with 32 elements in your batch and testing one image.
That’s it (if I’m guessing your dimensions correctly):

  • Training: 32 x num_channels x width x height
  • Testing: 1 x num_channels x width x height

Hope it helps

thanks for reply.but my program is error. below is part of my code:


do you know what happen? thanks

You shouldn’t wrap your DataLoader instance into a sampler.RandomSampler.
Just use this loop:

for data in test_loader:
    img, label = data

# or

for img, label in test_loader:
    # your training code

first,very thanks for reply.i adopt your advise,but there is a error: the code of
hookdoesn’t work, i don’t know the reason.