I have tensors of shape N x R x C x H x W (output of ROI pooling). To average across last two dimensions, I currently do:
x.view(x.size()[:3] + (-1,)).mean(-1)

Is there a simpler or more elegant way by using torch.nn.functional.adaptive_avg_pool2d or torch.nn.functional.adaptive_avg_pool3d?