i have changed my net structure like this:
class CNN(nn.Module):
def init(self,size):
    super(CNN, self).__init__()
    resnet = models.resnet152(pretrained=False)
    modules = list(resnet.children())[:-1]      # delete the last fc layer.
    self.resnet = nn.Sequential(*modules)
    self.linear = nn.Linear(resnet.fc.in_features, size)
    self.bn = nn.BatchNorm1d(size, momentum=0.01)
   
            
def forward(self, images):
    """Extract feature vectors from input images."""
    
    with torch.no_grad():
        features = self.resnet(images)
        
    features = features.reshape(features.size(0), -1)
    
    features = self.bn(self.linear(features))

features = self.linear(features)
    return features

the output shape like this:
BatchNorm2d-494            [-1, 512, 7, 7]           1,024
ReLU-495            [-1, 512, 7, 7]               0
Conv2d-496            [-1, 512, 7, 7]       2,359,296
BatchNorm2d-497            [-1, 512, 7, 7]           1,024
ReLU-498            [-1, 512, 7, 7]               0
Conv2d-499           [-1, 2048, 7, 7]       1,048,576
BatchNorm2d-500           [-1, 2048, 7, 7]           4,096
ReLU-501           [-1, 2048, 7, 7]               0
Bottleneck-502           [-1, 2048, 7, 7]               0
Conv2d-503            [-1, 512, 7, 7]       1,048,576
BatchNorm2d-504            [-1, 512, 7, 7]           1,024
ReLU-505            [-1, 512, 7, 7]               0
Conv2d-506            [-1, 512, 7, 7]       2,359,296
BatchNorm2d-507            [-1, 512, 7, 7]           1,024
ReLU-508            [-1, 512, 7, 7]               0
Conv2d-509           [-1, 2048, 7, 7]       1,048,576
BatchNorm2d-510           [-1, 2048, 7, 7]           4,096
ReLU-511           [-1, 2048, 7, 7]               0
Bottleneck-512           [-1, 2048, 7, 7]               0
AdaptiveAvgPool2d-513           [-1, 2048, 1, 1]               0
Linear-514                   [-1, 10]          20,490
BatchNorm1d-515                   [-1, 10]              20