I’m not sure, which setup throws this error, since I’ve tried a few and all seem to work:
previous_conv = torch.randn(1, 3, 4, 4)
num_sample = 1
previous_conv_size = [3, 3]
out_pool_size = [2, 2]

spatial_pyramid_pool(previous_conv, num_sample, previous_conv_size, out_pool_size)

Could you post a code snippet to reproduce this issue?
PS: I’ve formatted your code so that I could easily copy it. You can add code snippets by wrapping them in three backticks ```