Question about the implementation of Siamese network

the model’s forward function is

def forward(self,x0, x1)
    output1 = self.forward_once(x0)
    output2 = self.forward_once(x1)
    return output1,output2

So, are the following two implementations different?

output1,output2 = model(x0, x1)
loss = criterion (output1,output2)

And here is the another way:

output1 = model.forward_once(x0)
output2 = model.forward_once(x1)
loss = criterion (output1,output2)

Are they different?

Both approaches should be equal, even though I would suggest to use the former, as this will call the internal __call__ method, which properly registers all hooks etc.
Do you see and differences between both?

Yes. I tried the second one and got a overfitting. I didn’t try the first one, but just found the following implementation is also ok.

input_cat =[x0,x1],0)
output_cat = model(input_cat ) 
loss = criterion (first half of output_cat , second half of output_cat)