Replace Net with VGG16 without any error

class Net(nn.Module):
def init(self):

   super(Net, self).__init__()
   self.conv1 = nn.Conv2d(1, 32, 3, 1)
   self.conv2 = nn.Conv2d(32, 64, 3, 1)
   self.dropout1 = nn.Dropout2d(0.25)
   self.dropout2 = nn.Dropout2d(0.5)
   self.fc1 = nn.Linear(9216, 128)
   self.fc2 = nn.Linear(128, 10)

def get_features(self, x):
    x = self.conv1(x)
    x = F.relu(x)
    x = self.conv2(x)
    x = F.max_pool2d(x, 2)
    x = self.dropout1(x)
    x = torch.flatten(x, 1)
    x = self.fc1(x)
    return x

My goal is to replace this Net model with a VGG16 pre-trained model without any errors. Nevertheless, I received the following error: ValueError: only one element tensor can be converted to Python scalars. Is there a need to add additional layers like fully connected layers to feature_extractor? (nn.Sequential(*list(model.children())[:-1]))

It’s unclear where the error is raised and how this model should be replaced with a VGG16 model, so could you explain your use case a bit more and post a code snippet which raises the current error?