TypeError: max_pool2d(): argument 'kernel_size' (position 2) must be tuple of ints, not tuple

def pool2d(tensor, type= ‘max’):
sz = tensor.size()
if type == ‘max’:
x = torch.nn.functional.max_pool2d(tensor, kernel_size=(sz[2]/8, sz[3]) )
if type == ‘mean’:
x = torch.nn.functional.mean_pool2d(tensor, kernel_size=(sz[2]/8, sz[3]) )
x = x[0].cpu().data.numpy()
x = np.transpose(x,(2,1,0))[0]
return x

TypeError: max_pool2d(): argument ‘kernel_size’ (position 2) must be tuple of ints, not tuple

I am facing above error and I am not sure what is the fix for this, please provide some help.

The first value of the tuple is a float so use:

x = torch.nn.functional.max_pool2d(tensor, kernel_size=(sz[2]//8, sz[3]))

and it should work.

@ptrblck That was spot on, thank you so much :slight_smile: