You used AdaptiveMaxPool2d wrong, it should be nn.AdaptiveMaxPool2d((1, 5)). By setting the 2nd arg as 5, you are setting return_indices to a True value. http://pytorch.org/docs/master/nn.html#torch.nn.AdaptiveMaxPool2d 179