C3W2A_Assignment Center Cropping

I ran into exactly the same issue. I also suspect it is an environment issue that was not tested. In fact, if look at the code here (see code below), it is supposed to work and yet it fails with exactly the same error message you and I ran into at the beginning, that is the par where it complains “TypeError: ‘builtin_function_or_method’ object is not iterable”.

import torch
from torchvision.transforms import RandomAffine, RandomRotation, CenterCrop, Resize

batch_size = 128
channels = 3
H = 224
W = 224

images = torch.rand((batch_size, channels, H, W))

images = images.to('cuda:0')

affine = RandomAffine(degrees=0., translate=(0.1,0.1))
rotate = RandomRotation(9)
center = CenterCrop((24,24))
resize = Resize((32,32))

images = affine(images)
images = rotate(images)
images = center(images)
images = resize(images)

print(images.size())

1 Like