While trying to access the Targets attribute of the ImageFolder-
valdata = datasets.ImageFolder("../input/chest_xray/chest_xray/val", transform = transform)
valloader = torch.utils.data.DataLoader(valdata, shuffle = True, batch_size = 64 )

print(valdata.class_to_idx)
print(valdata.classes)
print(valdata.targets)
for i in valdata.samples:
    print(i)

I get this error-
{'NORMAL': 0, 'PNEUMONIA': 1}
['NORMAL', 'PNEUMONIA']
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-46-a7c7858221ef> in <module>()
     20 print(valdata.class_to_idx)
     21 print(valdata.classes)
---> 22 print(valdata.targets)
     23 for i in valdata.samples:
     24     print(i)

AttributeError: 'ImageFolder' object has no attribute 'targets'