# Something weird with ImageFolder

**URL:** <https://discuss.pytorch.org/t/something-weird-with-imagefolder/40232>\
**Category:** Uncategorized\
**Created:** [March 19, 2019, 2:12am UTC](https://discuss.pytorch.org/t/something-weird-with-imagefolder/40232 "2019-03-19T02:12:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John1231983](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/john1231983/32/4040_2.png) [@John1231983](https://discuss.pytorch.org/u/John1231983)\
**Post date:** [March 19, 2019, 2:12am UTC](https://discuss.pytorch.org/t/something-weird-with-imagefolder/40232/1 "2019-03-19T02:12:37Z")

</div>

I am using Imagefolder for classification task. My dataset is

```auto
animal_train
|-cat
     |-11.png
     |-12.png
|-dog
    |-21.png
    |-22.png
...
animal_val
|-cat
     |-11s.png
     |-12s.png
|-dog
    |-21s.png
    |-22s.png

```

I used code

```auto

transform = transforms.Compose(
    [transforms.RandomHorizontalFlip(),
    transforms.Resize(224),
    transforms.RandomCrop(112),        
    transforms.ToTensor(),
    transforms.Normalize(mean=(0.5,0.5,0.5),std=(0.5,0.5,0.5))])

train_loader = torch.utils.data.DataLoader(ImageFolder('./animal_train', transform=transform), 
                                                batch_size=16, shuffle=True, num_workers=4)
val_loader = torch.utils.data.DataLoader(ImageFolder('./animal_val', transform=transform), 
                                                batch_size=4, shuffle=False, num_workers=4)

```

I got very high accuracy for training but validation still zero. What is happening in my code?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [March 19, 2019, 12:35pm UTC](https://discuss.pytorch.org/t/something-weird-with-imagefolder/40232/2 "2019-03-19T12:35:53Z")

</div>

If you are dealing with two classes, the random accuracy should be around 0.5 instead of a perfect 0 (flipping the predictions would yield a perfect score of 1.0).

Could you post the code to calculate the validation predictions and accuracy so that we could have a look?
