Could you post the error message?
The output of nn.AvgPool3d is a tensor, which can be viewed as you want.
This code snippet demonstrates it:


class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.pool = nn.AvgPool3d(kernel_size=(2, 7, 7), stride=(1, 1, 1))
        self.fc = nn.Linear(3*23*18*18, 10)
        
    def forward(self, x):
        x = self.pool(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x

model = MyModel()
x = torch.randn(1, 3, 24, 24, 24)
out = model(x)