-
I'm not sure if we were supposed to apply the same transformations to the images in this exercise that we did to the MNIST images, but I did attempt to do so. I got a type error, I think when it was trying to resize the images (based on the trace), saying: TypeError: Tensor is not a torch image. When I tried to fix that by using Image.fromarray (and some other attempts to turn it into a torch image), I got an error saying it couldn't determine the dtype of the array. I thought since the Fashion MNIST images were similar to the classic MNIST ones that it would be easy to apply the same transforms, but apparently I was wrong LOL. Any clues you can give me on where I went wrong? THanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Interesting! You mean the following data transforms? data_transforms = {
"train": transforms.Compose(
[
transforms.Resize(32),
transforms.RandomCrop((28, 28)),
transforms.ToTensor(),
# normalize images to [-1, 1] range
transforms.Normalize((0.5,), (0.5,)),
]
),
"test": transforms.Compose(
[
transforms.Resize(32),
transforms.CenterCrop((28, 28)),
transforms.ToTensor(),
# normalize images to [-1, 1] range
transforms.Normalize((0.5,), (0.5,)),
]
),
}
train_dataset = MyDataset(
csv_path="mnist-pngs/new_train.csv",
img_dir="mnist-pngs/",
transform=data_transforms["train"],
)
train_loader = DataLoader(
dataset=train_dataset,
batch_size=32,
shuffle=True, # want to shuffle the dataset
num_workers=2, # number processes/CPUs to use
) Maybe try adding a [
transforms.ToPILImage(),
transforms.Resize(32),
transforms.CenterCrop((28, 28)),
transforms.ToTensor(),
# normalize images to [-1, 1] range
transforms.Normalize((0.5,), (0.5,)),
] |
Beta Was this translation helpful? Give feedback.
Interesting! You mean the following data transforms?