ptrblck:

def forward(self,x): residual = x out = F.relu(self.conv1(x)) out = F.relu(self.conv2(out)) out += residual out = out.view(out.size(0),-1) return self.classifier(out)


Thanks for the great snippet! I just have one question. With additional blocks is the residual added like this:
def forward(self,x):
        #First block
        residual = x
        out = F.relu(self.conv1(x))
        out = F.relu(self.conv2(out))
        
        out += residual
        
        #Second block
        out = F.relu(self.conv1(x))
        out = F.relu(self.conv2(out))
        
        out += residual

        out = out.view(out.size(0),-1)
        return self.classifier(out)

or like this:
def forward(self,x):
        #First block
        residual1 = x
        out = F.relu(self.conv1(x))
        out = F.relu(self.conv2(out))
        
        out += residual1
        residual2 = out

        #Second block
        out = F.relu(self.conv1(x))
        out = F.relu(self.conv2(out))
        
        out += residual2

        out = out.view(out.size(0),-1)
        return self.classifier(out)

Clarification is much appreciated. I dont seem to be able to de-code the pytorch vision model