thanks ,it works for me.
but I have another problem, I want to delete the linear layers in vgg16 pretrained and use the output tensor of the latest layer of vgg16 pretrained before fc layers, as input of the self.Global_1.
but I got the error :
AttributeError: ‘Sequential’ object has no attribute ‘features’
class attention_block(nn.Module):
def init(self):
super(attention_block, self).init()
self.vgg16 = models.vgg16(pretrained=True) 
self.vgg16 =list(self.vgg16 .children())[0][:-1]

print(self.vgg16)

self.vgg16.to(device)
for param in self.vgg16.features.parameters():
  param.requires_grad = False

self.Global_1 = nn.Conv2d(512,128,kernel_size=3, padding=1)
self.conv2_bn6= nn.BatchNorm2d(128)
self.Global_2 = nn.Conv2d(128,128,kernel_size=3, padding=1)
self.conv2_bn7= nn.BatchNorm2d(128)
self.Global_features = nn.Conv2d(128,128,kernel_size=1, padding=1)
self.Global_Score = nn.Conv2d(128,2,kernel_size=1, padding=1)


############################################################################
#fully connected
self.fc1 = nn.Linear(10*10* 208, 64)
self.fc2 = nn.Linear(64,32)
self.fc3 = nn.Linear(32,2)
##############################################################################

def forward(self, x):
out = self.vgg16(x)
print(out.shape)
Global_Score = self.Global_Score(self.Global_features(F.relu(self.conv2_bn7(self.Global_2(F.relu(self.conv2_bn6(self.Global_1(out))))))))
Global_Score = Global_Score.repeat(1, 64, 1, 1)



final_out= torch.sigmoid(F.dropout(self.fc3(torch.sigmoid(F.dropout(self.fc2(torch.sigmoid(F.dropout(self.fc1(Global_Score .view(Global_Score .size(0),-1))))))))))

return final_out