AdaptiveAvgPool2d gives TypeError: 'tuple' object is not callable

I want to check the results of AdaptiveAvgPool2d.
I built a simple test:

import torch
import torch.nn as nn

total = 256 * 500 * 4 * 4
x = torch.arange(0, total).view(256, 500, 4, 4).float()
p = nn.AdaptiveAvgPool2d(1),
res = p(x)

I’m getting error:

—> 7 res = p(x)

TypeError: ‘tuple’ object is not callable

  1. Why I’m getting this error ?
  2. How can I run AdaptiveAvgPool2d on my created tensor and check the results ?

there is a typo, change it to p = nn.AdaptiveAvgPool2d(1) (remove ‘,’)