train_dataset = dsets.CIFAR100(root=’…/…/data/’,
images, labels = train_dataset
images = Variable(image.cuda()) # error!
labels = Variable(label.cuda())
outputs = resnet(images)
loss = criterion(outputs, labels)
I want to convert it to a net inputs, and calc net’s gradients
How to convert image to Variable?
u need to use torch.utils.data.DataLoader, u can check it here
In general，i use torch.utils.data.DataLoader to load image, but i have to filter some images with images dataset. how to filter some images what i don’t to use with torch.utils.data.DataLoader?
I don’t know how to do it with dataloader, maybe u need to do it by yourself, u need to write a function to filter the images.
Make sure your
torch.utils.data.DataLoader is not neccessary, just rewrite your
__getitem__ and `len`` to filter some images.
thanks, sometime,i find pytorch data type converting is diffcult
thank you, i have used some other way to do it.