Why does out varies in both of these executions:
Execution 1:
input=torch.rand(2,3,32,32)
resnet18 = models.resnet18(pretrained=True)
output1=resnet18(input)
Execution 2:
model_1=resnet18
c=model_1.children
children=[]
for item in c():
    children.append(item)
class CHILD(torch.nn.Module):
def __init__(self):
    super(CHILD, self).__init__()
    self.models = nn.ModuleList(children).eval()     
    
def forward(self, x):
    for ii,model in enumerate(self.models):
        print(np.shape(x))
        print(model)
        if ii==9:
            x = torch.flatten(x,0)
        x=model(x)
    return x

MOD=CHILD()
output2=MOD(d1)
I observed that output1 is not same as output2
I guess it is because of the residual connections, which have been omitted in second case, If my point is correct then plz suggest me the way to know the position of residual connections (if from the
model’s definition its not clear to me), so that I can match the second case with the actual case.