ResNet50 Error with Multiple outputs

I am trying to modify the resnet50 to give multiple outputs .However I am getting a Dimension Mismatch Error
This is my code

class ResNet(nn.Module):
    def __init__(self):
        super(ResNet, self).__init__()
        resnet = models.resnet50(pretrained=True)
        modules = list(resnet.children())[:-1]
        self.resnet = nn.Sequential(*modules)

    def forward(self, x):

        x1 = self.resnet(x)  
        x1 = x1.view(x1.size(0), -1)  
        x2 = self.resnet(x) 
        x2= x2.view(x2.size(0), -1)
        return x1,x2

Would this answer from the other topic work?